Bnaya

howtoclassprop

Nov 12th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class MyClass {
  2.  
  3.     arr = [];
  4.  
  5.     constructor(width, height) {
  6.         this.makeArray(width, height);
  7.     }
  8.  
  9.     makeArray(width, height) {
  10.         this.arr = new Array(width * height);
  11.     }
  12. }
  13.  
  14. class MyClass2 {
  15.  
  16.     arr = [];
  17.  
  18.     constructor(width, height) {
  19.         this.width = width;
  20.         this.height = height;
  21.         this.makeArray();
  22.     }
  23.  
  24.     makeArray() {
  25.         this.arr = new Array(this.width * this.height);
  26.     }
  27. }
  28.  
  29. class MyClass3 {
  30.  
  31.     arr = [];
  32.  
  33.     constructor(width, height) {
  34.         this.arr = this.makeArray(width, height);
  35.     }
  36.  
  37.     makeArray(width, height) {
  38.         return new Array(this.width * this.height);
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment