daily pastebin goal
65%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 51 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top