...

View Full Version : Javascript Extension Method how do I make one??



code-in-time
05-30-2012, 06:08 PM
How do I make my own custom extention method like .replace("-","");

so for example:





function removeEs(text){

return text.replace("e","");
}


var s ="hello world";

var d = s.removeEs();

//d is now "hllo world"

Thanks

DaveyErwin
05-30-2012, 06:19 PM
String.prototype.removeEs = function (){

return this.replace("e","");
}


var s ="hello world";

alert(s.removeEs());


http://www.w3schools.com/jsref/jsref_prototype_string.asp



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum