This quiz covers some of the JavaScript operators in order to explain they can work together inside expressions. Assume that we have the following JavaScript code:
var object1 = {
valueOf: function () {
return 10;
},
toString: function () {
return "object1";
}
};
var object2 = {
valueOf: function () {
return 20;
},
toString: function () {
return "object2";
}
};
var object3 = {
valueOf: function () {
return 30;
},
toString: function () {
return "object3";
}
};
var result = (object2, object1, object3) + object1 +-- object1;
alert(result);
What is the output of the alert?
Read the complete answer
Published on April 08, 2013 11:17