JavaScript Quiz #3

Understanding JavaScript by example is useful for absorbing the different concepts of the language quickly. In this post, I will illustrate a quick JavaScript Quiz to understand how JavaScript (+) operator works. Assume that we have the following JavaScript code:



var object1 = {
someVar: 2,
someName: "object1",
valueOf: function () {
return this.someVar;
},
toString: function () {
return this.someName;
}
};

var result = "I equal " + object1;

alert(result); //What is the output of the alert?

What is the output of the alert?


Read the complete answer

 •  0 comments  •  flag
Share on Twitter
Published on April 02, 2013 16:58
No comments have been added yet.