William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

JavaScript: Empty Object Comparison

JavaScript: Empty Object Comparison

The following is my summary of empty object comparsion. They used in node command line.
They are slightly difference. For prototype inheritance, always use var o={};

var o; //undefined var o=null; //for empty object var o={}; //distinct a object
var o; var o=null; var o = {};
o.__proto__; //Error o.__proto__; //Error o.__proto__; // {}
o.constructor; //Error o.constructor; //Error o.constructor; // [Function: Object]
o.instanceof Object; //false o.instanceof Object; //false; o instanceof Object; // true
typeof o; //’undefined’ typeof t; //’object’ typeof o; // ‘object’
o; //undefined o; //null o; //{}
o.length; // Error o.length; //Error o.length; //undefined
o.toString(); //Error o.toString(); //Error o.toString(); //[object Object]
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: