Web Designer? Design and market your own professional website with easy-to-use tools.
Compare, review and buy thousands of Laptops , software products at CheckCost.co.uk
Your Text Link Here! and your text description here!
The string object of javascript allows you to manipulate a stored piece of text.
The prototype property allows you to add custom properties/methods to an object.
The javascript code example below shows you how to use the prototype property to add a method to an object.
The javascript code below outputs an alert box with the text "John Smith".
<script type="text/javascript" language="javascript">
function Name(first, last)
{
this.first = first;
this.last = last;
}
var person = new Name("John", "Smith");
Name.prototype.toString = function()
{
return this.first + " " + this.last;
}
alert( person );
</script>