Guest User

Untitled

a guest
Apr 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. MyClass.operator.lookup(index)
  2. {
  3. return myArray[index];
  4. }
  5.  
  6. MyClass = function(){
  7. // Set some defaults that belong to the class via dot syntax or array syntax.
  8. this.some_property = 'my value is a string';
  9. this['another_property'] = 'i am also a string';
  10. this[0] = 1;
  11. };
  12.  
  13. foo = new MyClass();
  14. foo.some_property; // Returns 'my value is a string'
  15. foo['some_property']; // Returns 'my value is a string'
  16. foo.another_property; // Returns 'i am also a string'
  17. foo['another_property']; // Also returns 'i am also a string'
  18. foo.0; // Syntax Error
  19. foo[0]; // Returns 1
  20. foo['0']; // Returns 1
  21.  
  22. MyClass.operator.lookup(index)
  23. {
  24. get { return myArray[index]; }
  25. set { myArray[index] = value; }
  26. }
Add Comment
Please, Sign In to add comment