JSFiddle - React, Tailwind, and code Playground
by Khalil Zhang
JavaScript
var obj = {
name: 'holmes',
toString: function() {
return "I'am " + this.name;
},
valueOf: function() {
return 1;
}
};
alert(obj); //I'am holmes
alert([obj, 'FE'].join(' ')); //I'am holmes FE
alert(obj + 'Holmes'); //1Holmes
alert(obj + 100); //101
alert(++obj); //2
Object.prototype.toString.call([]); // '[object Array]'
Object.prototype.toString.call({}); // '[object Object]'
Object.prototype.toString.call(Number(1)); // '[object Number]'
Object.prototype.toString.call(new Number(1)); // '[object Number]'
Object.prototype.toString.call(Boolean(1)); // '[object Boolean]'
Object.prototype.toString.call(true); // '[object Boolean]'