Friday, November 28, 2008

construnctor of javascript

the superclass of all JavaScript objects
new Object( );
This constructor creates an empty object to which you can add arbitrary properties.

All JavaScript objects, how ever they are created, have the following properties.

var f = function(){}
var g = function(){}
var f1 = new f();
var f2 = new f();
var g1 = new g();
console.log(f.constructor); // Function()
console.log(g.constructor); // Function()
console.log(f.constructor == g.constructor); // true
console.log(f1.constructor); // function() [f]
console.log(g1.constructor); // function() [g]
console.log(f1.constructor == g1.constructor); // false
console.log(f1.constructor == f2.constructor); // true
console.log(f1.constructor === f2.constructor); // true

No comments :