Trying to learn how to use classes with javascript, not sure how to initialize class correctly -


not sure why construction of class not working, maybe i'm calling function in wrong way? here code:

  function zeros(bits, pattern) {     this.bits = bits;     this.pattern = pattern;   };    zeros.prototype.short = function() {     return this.bits.match(this.pattern)[0].length;   };    heyjude = zeros('1100110011001100000011000000111111001100111111001111110000000000000011001111110011111100111111000000110011001111110000001111110011001100000011', /([0]).*?\1+/);   console.log(heyjude.short()); 

call via new keyword:

var heyjude = new zeros('...'); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

ios - MKMapView fails to load tiles with HTTP 410 error -

c# - How to utilize EF and LINQ to add filters and specify tables, columns, filters and order by dynamically -