I'm having some troubles to understand what is copied and what is referenced in javascript. What is clear to me is that an object is referenced when it's an object and copied when it's a variable:
var reference = myObject // myObject = {string:'text'} -> referenced
var copy = myVar // myVar = 'text' -> copied
Now what if I want to create an object of objects/var?
var newObject = {anObject: myObject, aVar: myVar}
Will they be copied or referenced? If they are copied, is there a way to make them referenced (at least the object: myObject)?
Edit (Angularjs specific): I wanted to make sure that everything answered is also true with AngularJS and the $rootScope variables (even though I guess the behavior should be identical)