Skip to content

Instantly share code, notes, and snippets.

@bgorkem
Created May 7, 2014 11:00
Show Gist options
  • Save bgorkem/1c5bc06028c1b4a6023d to your computer and use it in GitHub Desktop.
Save bgorkem/1c5bc06028c1b4a6023d to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]" />
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
console.clear();
var base = { type:'base', id:12, age:40};
var ctor =function() {
this.gender = 'M'; // add new property
this.type = 'sub'; //override type
};
ctor.prototype = base;
var c = new ctor();
c.age = 42; // override base
console.log('instance c ' , c);
var d = new ctor();
console.log('instance d ' , d);
console.log('constructor base:', ctor.prototype);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment