Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript prototype chaining in stackoverf

function Parent(){}

Parent.prototype.say = function () {
return 20;
};

function Child(){
}

Child.prototype.say = function () {
return 10;
};

inherit(Child, Parent);

function inherit(C, P) {
C.prototype = P.prototype;
 } 

 var parent = new Parent();
var child = new Child();


var child2 = new Child()
alert(child.say(); //20
alert(parent.say()); //20
alert(child2.say()); //20
Comment

PREVIOUS NEXT
Code Example
Javascript :: Copy an Array with the Spread Operator 
Javascript :: iterate set javascript 
Javascript :: object empty or undefined 
Javascript :: crypto digest node.js 
Javascript :: object.keys map 
Javascript :: filebase64 template 
Javascript :: add html symbols with javascript 
Javascript :: hover inline css 
Javascript :: js parse money value 
Javascript :: how to parse arguments to a promise in javascript 
Javascript :: javascript intersect two object arrays 
Javascript :: firestore get first document in collection and delete it 
Javascript :: scriptcase javascript close modal form 
Javascript :: how to change div style to full page react 
Javascript :: nuxt js index.html not found 
Javascript :: c# to json online 
Javascript :: (error) => { console.log(error); } 
Javascript :: nodejs how to beautify mysql arrays 
Javascript :: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace 
Javascript :: react-native-page-control 
Javascript :: jQuery - The noConflict() Method 
Javascript :: How to switch to a remote git branch that does not exist locally 
Javascript :: react jsx hello react sample 
Javascript :: Passing arrays to functions with the spread operator 
Javascript :: _.extend Example 
Javascript :: Changing Prototype 
Javascript :: pass data between componets in react 
Javascript :: Scale to fit 
Javascript :: Parsing the URL string using the Legacy API 
Javascript :: mobile version 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =