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 create(obj) {
    var newObj = function () {};
    obj.prototype = new newObj();
    
    return obj;
}
var pr = { a: 1, b: 2 }; // объект который станет прототипом
var newObj = create(pr);
newObj.a = 10;
console.log(newObj); // отладчиком убедись что у newObj есть прототип
console.log(newObj.a); // 10
console.log(newObj.b); // 2
console.log(newObj === pr); // false
console.log(pr.isPrototypeOf(newObj)); // true
// Удедимся что исходный объект не поменялся
console.log(pr.a); // 1
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers