Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- callback instanceof Function
- typeof callback == "function"
- alert(typeof undefinedVariable); // alerts the string "undefined"
- alert(undefinedVariable instanceof Object); // throws an exception
- var myNullVar = null;
- alert(typeof myNullVar ); // alerts the string "object"
- alert(myNullVar instanceof Object); // alerts "false"
- function isFunction(obj) {
- return typeof(obj) == "function";
- }
- function isArray(obj) {
- return typeof(obj) == "object"
- && typeof(obj.length) == "number"
- && isFunction(obj.push);
- }
- var str = 'hello word';
- str instanceof String // false
- typeof str === 'string' // true
- var ClassFirst = function() { };
- var ClassSecond = function() { };
- var instance = new ClassFirst();
- console.log(typeof instance); //returns object
- console.log(typeof instance == 'ClassFirst'); //obviously this one is false
- console.log(instance instanceof Object); //true
- console.log(instance instanceof ClassFirst); //true
- console.log(instance instanceof ClassSecond); //false
- callback instanceof Function
Add Comment
Please, Sign In to add comment