Skip to content

Instantly share code, notes, and snippets.

@rsolomo
Created October 25, 2016 22:44
Show Gist options
  • Save rsolomo/c134d4bf5b08fd7ad58d1300934a84f7 to your computer and use it in GitHub Desktop.
Save rsolomo/c134d4bf5b08fd7ad58d1300934a84f7 to your computer and use it in GitHub Desktop.
new class vs new function prototype
function Foo1() {
}
Foo1.prototype.interact = function() {
this.dispose = true
}
class Foo2 {
interact() {
this.dispose = true
}
}
console.log('Foo1')
console.log(Object.getOwnPropertyDescriptor(Foo1, 'prototype'))
console.log(Object.getOwnPropertyDescriptor(Foo1.prototype, 'interact'))
console.log()
console.log('Foo2')
console.log(Object.getOwnPropertyDescriptor(Foo2, 'prototype'))
console.log(Object.getOwnPropertyDescriptor(Foo2.prototype, 'interact'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment