Skip to content

Instantly share code, notes, and snippets.

@abozhilov
Created November 4, 2011 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save abozhilov/1339681 to your computer and use it in GitHub Desktop.
Save abozhilov/1339681 to your computer and use it in GitHub Desktop.
setPrototypeOf
function setPrototypeOf(obj, proto) {
var p = proto;
do {
if (obj === p) {
throw Error('Circular prototype chain');
}
} while (p = Object.getPrototypeOf(p));
obj.__proto__ = proto;
return obj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment