เปรียบเทียบการเชคค่า object
var ClassFirst = function () {};
var ClassSecond = function () {};
var example = new ClassFirst();
typeof example; // object
typeof example == 'ClassFirst'; //false
instance instanceof Object; //true
instance instanceof ClassFirst; //true
instance instanceof ClassSecond; //false
เปรียบเทียบการเชคค่า primitive type
'example string' instanceof String; // false
typeof 'example string' == 'string'; //true
'example string' instanceof Object; //false
typeof 'example string' == 'object'; //false
true instanceof Boolean; // false
typeof true == 'boolean'; //true
99.99 instanceof Number; // false
typeof 99.99 == 'number'; //true
function() {} instanceof Function; //true
typeof function() {} == 'function'; //true
0 comments:
Post a Comment