var Widget = new Class({
Implements: Options,
options: {
color: '#fff',
size: {
width: 100,
height: 100
}
},
initialize: function(options){
this.setOptions(options);
}
});
var myWidget = new Widget({
color: '#f00',
size: {
width: 200
}
});
//myWidget.options is now: {color: #f00, size: {width: 200, height: 100}}
// Deep copy example
var mySize = {
width: 50,
height: 50
};
var myWidget = new Widget({
size: mySize
});
(mySize == myWidget.options.size) // false! mySize was copied in the setOptions call.
from here
myWidget.options.size should be also
{
width: 50,
height: 50
};
Why is (mySize == myWidget.options.size) // false! ?
Something like that won’t work because it doesn’t checks the values of the objects, but the identity of the objects:
So if you want to compare two object you have to write something like that