Function.prototype : Function Object : Function JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Function » Function Object »

 

Function.prototype










Syntax








function.prototype.property
    function.prototype.method



The prototype property refers to the object that serves as the prototype from which classes are created.

prototype allows you to add new properties of methods to an existing class by adding them to the prototype associated with the constructor of that class.












<html>
    <body>
    <script lanuguage="JavaScript">
    <!--
    var mytask = new String();

    function setTask(str){
        var task="task a";
        if(str != null){
         task = str;
        }
        return task;
    }
    String.prototype.duty = setTask;
    document.write("The first task is: " + mytask.duty("Nothing""<br>");
    document.write("The next task is: " + mytask.duty());
    -->
    </script>
    </body>
    </html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Function
» Function Object