Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
function Parent(){
}
Parent.prototype = {
 primitive : 1,
 object : {
    one : 1
 }
};
function Child(){
}
Child.prototype = Object.create(Parent.prototype);
Child.prototype.constructor = Child;
Child.prototype.changeProps = function(){
    this.primitive = 2;
    this.object.one = 2;
};
var dad = new Parent();
var son = new Child();
son.changeProps();
console.log(dad.primitive); /* 1 */
console.log(son.primitive); /* 2 */
console.log(dad.object.one); /* 2 */
console.log(son.object.one); /* 2 */
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers