Created
June 11, 2013 16:53
-
-
Save prdanelli/5758551 to your computer and use it in GitHub Desktop.
Example JS Module example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// module... | |
// encapculates the properties of the function | |
// returns the function | |
String.method('deentity', function(){ | |
var entities = { | |
quote: '"', | |
lt: '<', | |
gt: '>' | |
}; | |
return function(){ | |
return this.replace(/&([^&;]+);/g, function(a, b){ | |
var r = entities[b]; | |
return typeof r === 'string' ? r : a; | |
}); | |
} | |
}); | |
document.writeln('"This is the test >>>>...."'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment