Guest User

Untitled

a guest
Sep 15th, 2015
72
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Person(name) {
  2.   // "instance" variable
  3.   this.name = name;
  4. }
  5.  
  6. // "static" variable
  7. Person.TYPE = 'mammal';
  8.  
  9. var me = new Person('Impaloo');
  10. me.name; // 'Impaloo'
  11. me.TYPE; // undefined
  12.  
  13. Person.TYPE // 'mammal'
  14.  
  15.  
  16.  
  17. // Or with ECMAScript 2015
  18.  
  19. class Person {
  20.   constructor(name) {
  21.     this.name = name;
  22.   }
  23.  
  24.   static hasStaticMethodSyntax() {
  25.     return "foobar";
  26.   }
  27. }
  28.  
  29. Person.TYPE = 'static non-functions would be defined here';
RAW Paste Data