Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Array.prototype = new Parser()
- function() { return this.list.shift() }
- function Parser() {
- this.get_info_colors = function() {
- return {
- 'id': self.shift(),
- 'name': self.shift(),
- 'colors': self.get_colors()
- }
- }
- this.get_info_grad = function() {
- return {
- 'id': self.shift(),
- 'name': (self.shift() + '_grad'),
- 'grad': self.shift()
- }
- }
- this.get_colors = function() {
- this.shift();
- var result = [],
- element;
- while(element != ']') {
- element = this.shift();
- result.push();
- }
- return element;
- }
- this.builder = function(factory) {
- this.shift();
- var result = [],
- element;
- while(element != ']') {
- result.push(factory());
- }
- return result;
- }
- this.color_builder = function() {
- return this.builder(this.get_info_colors);
- }
- this.grad_builder = function() {
- return this.builder(this.get_info_grad);
- }
- }
- function CustomArray() {}
- CustomArray.prototype = Object.create(Array.prototype);
- CustomArray.constructor = CustomArray;
- CustomArray.prototype.newMethod = function() {...}
- Parser.prototype = [];
- function Parser() { this.__a = 1; }
- Parser.prototype = [];
- var a = new Parser;
- a.length
- // gives 0
- a.push( 2 );
- // gives 1
- a.length
- // gives 1
- a.__a
- // gives 1
- function Parser() {
- var args = [].slice.call( arguments );
- args.unshift( 0 );
- args.unshift( 0 );
- [].splice.apply( this, args );
- }
- Parser.prototype = [];
- var c = new Parser( 1, 2, 3 )
- c.length
- // gives 3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement