Guest User

Untitled

a guest
Jun 14th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. callback instanceof Function
  2.  
  3. typeof callback == "function"
  4.  
  5. alert(typeof undefinedVariable); // alerts the string "undefined"
  6. alert(undefinedVariable instanceof Object); // throws an exception
  7.  
  8. var myNullVar = null;
  9. alert(typeof myNullVar ); // alerts the string "object"
  10. alert(myNullVar instanceof Object); // alerts "false"
  11.  
  12. function isFunction(obj) {
  13. return typeof(obj) == "function";
  14. }
  15. function isArray(obj) {
  16. return typeof(obj) == "object"
  17. && typeof(obj.length) == "number"
  18. && isFunction(obj.push);
  19. }
  20.  
  21. var str = 'hello word';
  22.  
  23. str instanceof String // false
  24.  
  25. typeof str === 'string' // true
  26.  
  27. var ClassFirst = function() { };
  28. var ClassSecond = function() { };
  29. var instance = new ClassFirst();
  30. console.log(typeof instance); //returns object
  31. console.log(typeof instance == 'ClassFirst'); //obviously this one is false
  32. console.log(instance instanceof Object); //true
  33. console.log(instance instanceof ClassFirst); //true
  34. console.log(instance instanceof ClassSecond); //false
  35.  
  36. callback instanceof Function
Add Comment
Please, Sign In to add comment