RSS
 

Renaming JavaScript Objects

19 Aug
javascript:var foo = {baz: 'bizzer'};
var bar = foo;
bar.baz = 'bazzer';
alert(foo.baz + ' == ' + bar.baz);

As you can see the object’s property of ‘baz’ is updated in both foo object and bar object (a copy or reference to foo).

VN:F [1.9.3_1094]
Rating: 7.5/10 (2 votes cast)
VN:F [1.9.3_1094]
Rating: +1 (from 1 vote)
Renaming JavaScript Objects, 7.5 out of 10 based on 2 ratings
Retweet
 
1 Comment

Posted in JavaScript

 
  1. Ronnie

    October 7, 2008 at 10:37 pm

    Sorry…

    VA:F [1.9.3_1094]
    Rating: 5.0/5 (1 vote cast)
    VA:F [1.9.3_1094]
    Rating: +1 (from 1 vote)