JavaScript objects... */ var object_1 = {a: 1}; // assign reference of newly created object to object_1 var object_2 = {a: 0}; var object_3 = object_2; // object_3 references the same object as object_2 does object_3.a = 2; message(); // displays 1 2 2 object_2 = object_1; // object_2 now references the same object as object_1 // object_3 still references what object_2 referenced before message(); // displays 1 1 2 object_2.a = 7; // modifies object_1 message(); // displays 7 7 2 object_3.a = 5; // object_3 doesn't change object_2 message(); // displays 7 7 5 object_3 = object_2; object_3.a=4; // object_3 changes object_1 and object_2 message(); // displays 4 4 4 /** * Prints the console.log message */ function message() { console.log(object_1.a + " " + object_2.a + " " + object_3.a); } Destructuring assignment In Mozilla's JavaScript, since version 1.7, destructuring assignment allows the assignment of parts of data structures to several variables at once. The left hand side of an assignment is a pattern that resembles an arbitrarily nested object/array literal containing l-lvalues at its leaves that are to receive the substructures of the assigned value. var a, b, c, d, e; [a, b, c] = [3, 4, 5]; console.log(a + ',' + b + ',' + c); // displays: 3,4,5 e = {foo: 5, bar: 6, baz: ['Baz', 'Content']}; var arr = []; ({baz: [arr[0], arr[3]], foo: a, bar: b}) = e; console.log(a + ',' + b + ',' + arr); // displays: 5,6,Baz,,,Content [a, b] = [b, a]; // swap contents of a and b console.log(a + ',' + b); // displays: 6,5 [a, b, c] = [3, 4, 5]; // permutations [a, b, c] = [b, c, a]; console.log(a + ',' + b + ',' + c); // displays: 4,5,3 Spread/rest operator The ECMAScript 2015 standard introduces the "..." operator, for the related concepts of "spread syntax" and "rest parameters" Spread syntax provides another way to destructure arrays. It indicates that the elements in a specified array should be used as the parameters in a function call or the items in an array literal. In other words, "..." transforms "[...foo]" into "[foo[0], foo[1], foo[2]]", and "this.bar(...foo);" into "this.bar(foo[0], foo[1], foo[2]);". var a = [1, 2, 3, 4]; // It can be used multiple times in the same expression var b = [...a, ...a]; // b = [1, 2, 3, 4, 1, 2, 3, 4];