Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. Array.prototype = new Parser()
  2.  
  3. function() { return this.list.shift() }
  4.  
  5. function Parser() {
  6. this.get_info_colors = function() {
  7. return {
  8. 'id': self.shift(),
  9. 'name': self.shift(),
  10. 'colors': self.get_colors()
  11. }
  12. }
  13. this.get_info_grad = function() {
  14. return {
  15. 'id': self.shift(),
  16. 'name': (self.shift() + '_grad'),
  17. 'grad': self.shift()
  18. }
  19. }
  20. this.get_colors = function() {
  21. this.shift();
  22. var result = [],
  23. element;
  24. while(element != ']') {
  25. element = this.shift();
  26. result.push();
  27. }
  28. return element;
  29. }
  30. this.builder = function(factory) {
  31. this.shift();
  32. var result = [],
  33. element;
  34. while(element != ']') {
  35. result.push(factory());
  36. }
  37. return result;
  38. }
  39. this.color_builder = function() {
  40. return this.builder(this.get_info_colors);
  41. }
  42. this.grad_builder = function() {
  43. return this.builder(this.get_info_grad);
  44. }
  45. }
  46.  
  47. function CustomArray() {}
  48. CustomArray.prototype = Object.create(Array.prototype);
  49. CustomArray.constructor = CustomArray;
  50.  
  51. CustomArray.prototype.newMethod = function() {...}
  52.  
  53. Parser.prototype = [];
  54.  
  55. function Parser() { this.__a = 1; }
  56. Parser.prototype = [];
  57. var a = new Parser;
  58. a.length
  59. // gives 0
  60. a.push( 2 );
  61. // gives 1
  62. a.length
  63. // gives 1
  64. a.__a
  65. // gives 1
  66.  
  67. function Parser() {
  68. var args = [].slice.call( arguments );
  69. args.unshift( 0 );
  70. args.unshift( 0 );
  71. [].splice.apply( this, args );
  72. }
  73.  
  74. Parser.prototype = [];
  75.  
  76. var c = new Parser( 1, 2, 3 )
  77. c.length
  78. // gives 3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement