Say we want to add methods to a certain type. For example, adding a trim function to the String type:
String.method(‘trim’, function ( ) {
return this.replace(/^s+|s+$/g, ”);
});
document.writeln(‘”‘ + ” neat “.trim( ) + ‘”‘);
Say we want to add methods to a certain type. For example, adding a trim function to the String type:
String.method(‘trim’, function ( ) {
return this.replace(/^s+|s+$/g, ”);
});
document.writeln(‘”‘ + ” neat “.trim( ) + ‘”‘);