Otimização de string JavaScript

String.prototype.equals = function(value) { return this.valueOf() === value.valueOf();}String.prototype.endsWith = function(value) { return this.indexOf(suffix, this.length – value.length) !== -1;}String.prototype.startsWith = function(value) { return this.indexOf(value) === 0;}String.prototype.isEmail = function() { re = …

Continuar lendo

Modelagem rápida em JavaScript

function compile_template(template) { return new Function(‘o’, ‘o=o||{};return “‘ + template .replace(/”/g, ‘\”‘) .split(‘{‘) .join(‘”+(o.’) .split(‘}’) .join(‘||””)+”‘) + ‘”;’ );} Use com uma sintaxe semelhante ao bigode “{varname}” var drawLink = …

Continuar lendo