How to create Extension methods for predefined datatype in JavaScript

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.


<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()