Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MyClass.operator.lookup(index)
- {
- return myArray[index];
- }
- MyClass = function(){
- // Set some defaults that belong to the class via dot syntax or array syntax.
- this.some_property = 'my value is a string';
- this['another_property'] = 'i am also a string';
- this[0] = 1;
- };
- foo = new MyClass();
- foo.some_property; // Returns 'my value is a string'
- foo['some_property']; // Returns 'my value is a string'
- foo.another_property; // Returns 'i am also a string'
- foo['another_property']; // Also returns 'i am also a string'
- foo.0; // Syntax Error
- foo[0]; // Returns 1
- foo['0']; // Returns 1
- MyClass.operator.lookup(index)
- {
- get { return myArray[index]; }
- set { myArray[index] = value; }
- }
Add Comment
Please, Sign In to add comment