Skip to content

Instantly share code, notes, and snippets.

@jk195417
Last active October 7, 2019 03:23
Show Gist options
  • Save jk195417/aba5d2dd80eeadbc65c98379cb9e2243 to your computer and use it in GitHub Desktop.
Save jk195417/aba5d2dd80eeadbc65c98379cb9e2243 to your computer and use it in GitHub Desktop.
var A = function() {}
A.prototype.value = 'a'
var B = function() {}
B.prototype = new A()
B.prototype.value = 'b'
new B().value // return 'b'
@jk195417
Copy link
Author

jk195417 commented May 8, 2019

var A = function() {}
A.prototype.value = 'a'
var B = function() {
 this.value = 'b'
}
B.prototype = new A()

new B().value // return 'b'

@lagagain
Copy link

lagagain commented May 8, 2019

var A = function() {}
A.prototype.value = 'a'
var a = new A()
var B = function() {}
B.prototype = A.prototype
B.prototype.value = 'b'

var b = new B()

a.value == b.value  // return true //wwwww

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment