javascript - suppress main function call with function defined in prototype -


have @ code below:

function person() {    this.fname = 'baby';    this.lname = 'boy';    this.walk = function () {      return 'i can walk';    }  }  person.prototype.walk=function(){ return 'all can walk';}      var obj=new person();    obj.walk();

now want let both these funtions in code want when make call walk using obj.walk()...it should calling walk function prototype,as result return me 'all can walk'

you can delete obj.walk remove property specific object, , force use inherited method.

function person() {    this.fname = 'baby';    this.lname = 'boy';    this.walk = function () {      return 'i can walk';    }  }  person.prototype.walk=function(){ return 'all can walk';}      var obj=new person();    delete obj.walk;    console.log(obj.walk());


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -