fumble icon indicating copy to clipboard operation
fumble copied to clipboard

Proper prototype chaining

Open Vijar opened this issue 10 years ago • 2 comments

@koulmomo is there any reason you inherit the prototype from the instance instead of chaining the class' prototype like the mdn link in comment specifies?

https://github.com/yahoo/fumble/blob/master/HttpError.js#L28

Vijar avatar Jun 09 '15 23:06 Vijar

@Vijar sigh. Unfortunately, the mdn link in the comments doesn't seem to be a permalink.

The link originally had the code under the comment as opposed to the Object.create method that is there now (which would require a polyfill).

The reason why you set the prototype to be a new Error instance is because you would otherwise overwrite the Error constructor for everything

koulmomo avatar Jun 10 '15 21:06 koulmomo

Looks like they updated the code on Jan 22nd: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error$compare?locale=en-US&to=728095&from=676225

ZeikJT avatar Jun 10 '15 23:06 ZeikJT