Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save robotarmy/869589 to your computer and use it in GitHub Desktop.
Save robotarmy/869589 to your computer and use it in GitHub Desktop.
javascript-instance-based-inheritance-v8console.js
> a = function() {}
function () {}
> print(a)
function () {}
> b = function(){}
function (){}
> b.prototype = a
function () {}
> a.my_hi = function() { print('my_hi') }
function () { print('my_hi') }
> b.constructor = a
function () {}
> myb = new b
<string conversion failed>
# this is v8 responding that it doesn't have a way to print the result of 'new'
> myb.my_hi()
my_hi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment