News for hackers. Stuff that matters.
Re:OO JS in 15mins or Less by SideburnsOfDoom on Monday April 30, 2012 @11:26AM (#3909627)
The text is quite misleading. Where it says "When using Object literals, if we copy an object and change a property or a method that method/property will be changed for all instances."

And in the code, there is only one instance. No copying has taken place, but there are two references to the same object.

Re:OO JS in 15mins or Less by dgreensp on Monday April 30, 2012 @11:49AM (#3909721)
Agreed, anyone who uses this as the beginner tutorial it is will be confused for a long time by words like "copy" and "clone" used to mean variable assignment. This is terrible teaching, or somehow the author has an exotic mental model of what the computer is doing.
Re:OO JS in 15mins or Less by mdgrech23 on Monday April 30, 2012 @12:21PM (#3909876)
Agreed. I could see how that line could be confusing. Why don't we change it for the better in that case? How about something like this:

In the example above we create a new variable sally, and assign it the value bill. Both sally and bill reference the same spot in memory. As such we can't change bill out w/ out changing Sally, specifically when a change is made to an object literal it will affect that object across the entire script.

Re:OO JS in 15mins or Less by SideburnsOfDoom on Friday May 04, 2012 @04:25AM (#3927566)
Today I learned that in ECMAScript5 (IE 9 onwards) there is also a function called Object.Create ( https://developer.mozilla.org/en/JavaScript/Reference/Global... ) which can be used to copy objects. Kinda.
Re:OO JS in 15mins or Less by SideburnsOfDoom on Monday April 30, 2012 @12:57PM (#3910084)
Something like that would be right.

How about: In the example above we create a new variable sally, and make it equal to bill. Both sally and bill now reference the same object in memory. Changes made via one affect both of them.

Re:OO JS in 15mins or Less by mdgrech23 on Monday April 30, 2012 @01:04PM (#3910127)
Awesome, you rock! Officially updated the post w/ the above :)
Re:OO JS in 15mins or Less by hammock on Monday April 30, 2012 @06:21PM (#3911869)
Can you do better in a fifteen-minutes-or-less summary? Or at least point to a better one?
Re:OO JS in 15mins or Less by johncoltrane on Monday April 30, 2012 @06:26PM (#3911890)
Maybe 15 minutes is not enough?