Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem understanding this code

 
Rajesh Khan
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i m currently going over an open source JS library and I am trying to comprehend it. I ran into something like this I deleted a lot of stuff in this code but i wanted to know what the extend method does , I believe its suppose to copy the properties of second into the first but whats after that ?? the extend function is not missing anything else. What does it do after copying the properties. IT neither returns the value and neither are the objects passed to this function global.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Since objects are passed by reference, you can not just store the values, you need to loop through them to make a copy.



Eric




 
Rajesh Khan
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric Pascarello wrote:

Since objects are passed by reference, you can not just store the values, you need to loop through them to make a copy.



Eric


Thanks Eric for clarifying that out. It helped a lot.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic