re: 10 JavaScript concepts you need to know for interviews VIEW POST

TOP OF THREAD FULL DISCUSSION
re: (Note: the original author has clarified the wording on this point since I wrote this. My note here applies to the original wording.) Great stuff,...
 

JavaScript passes functions by reference! So when you pass 'o', you are not passing the value { p: 'foo' }... you are passing its memory location which is named 'o' for readability. 'n' is a local variable inside your function that points to whatever value/reference you are passing to your function. n will refer to the same object o refers to. When you say n = { p: 'bar'}, n is now pointing to a "newly" created object that happens to have the same property 'p' as that of the one you passed to the function.

code of conduct - report abuse