In Javascript one can create extension(for eg: for string it can be obj.Trim(), obj.LTrim(), obj.RTrim etc) methods for predefined data types. These kind of methods can be created by using prototype property of datatypes.
Here In below code I am showing Extension methods for String DataType.
Now as we have written Two extension methods for string data types and suppose we have string variable called str then we can use these methods like str.LCase(), str.Trim().
Here In below code I am showing Extension methods for String DataType.
<script type="text/javascript" language="javascript"> String.prototype.LCase = function () { return this.toLowerCase(); } String.prototype.Trim = function() { return [Some PROCESSED VALUE];} </script>
Now as we have written Two extension methods for string data types and suppose we have string variable called str then we can use these methods like str.LCase(), str.Trim().
No comments:
Post a Comment