prototype in 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());