Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. typeof yourFunction === 'function'
  2.  
  3. typeof String.link === 'function' // false
  4. typeof String.link() === 'function' // Uncaught error ...
  5.  
  6. typeof String.prototype.link === 'function' //true
  7.  
  8. function foo(){
  9. alert('from foo');
  10. }
  11.  
  12. foo.bar = function(){
  13. alert('bar on foo');
  14. }
  15.  
  16. foo(); //from foo
  17. foo.bar(); //bar on foo
  18.  
  19. String//Defines the Object
  20. String.prototype//Defines the methods and properties that will be bound to a var of the type String
  21. 'foo'//This is a string
  22. 'foo'.link//So it has the link method
  23. String//This is an Objecy that defines the strings
  24. String.link//So it doesn't have the link method
  25. String.prototype//An object that stores the methods and properties of the vars of type String
  26. String.prototype.link//So it has the link method
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement