better.js icon indicating copy to clipboard operation
better.js copied to clipboard

instanceof

Open icylace opened this issue 11 years ago • 1 comments

I notice that you use instanceof a few times in your strong typing code.

Unfortunately, instanceof will not work correctly when dealing with multiple frames in a window. The MDN docs take note of this. There are those who consider instanceof to be ultimately worthless for that reason.

From what I've read on the subject Object.prototype.toString() is the current best replacement for instanceof.

For example, validator.js uses it.

icylace avatar Aug 02 '14 05:08 icylace

interesting point! How to handle your own class in this context ?

like

var MyClass = function(){
  console.log('super class')
}

jeromeetienne avatar Dec 08 '14 04:12 jeromeetienne