4
I think it’s great to have my own methods imported into the Javascript native objects.
For example:
String.prototype.hello = function(){
return this.toString() + ' hello';
}
'Say '.hello() // say hello
Number.prototype.add = function(){
return this + 1;
}
(1).add() // 2
But this practice is recommended?
Is there any downside to doing this? Or would it be a better practice to create my own object?
Duplicate? http://answall.com/questions/48070/addir-propriedades-ao-element-node Even if it is not, I believe that the same reasoning as my answer applies.
– bfavaretto
Very useful, @bfavaretto.
– Wallace Maxters