* Because the class string
should not instantiate it to use a function of its prototype? , example: *
String.prototype.mayus = function(){
return this.toUpperCase();
};
var frase = "mayusculas".mayus();
console.info(frase);
Now if I want to use a function of class Number
, I must instantiate it
WITHOUT INSTANCE:
Number.prototype.restar = function(d){
return d + (-d);
};
var b = restar(5);
console.info(b);
WITH INSTANCE:
Number.prototype.restar = function(d){
return d + (-d);
};
var k = new Number();
var b = k.restar(5);
console.info(b);