jeromeetienne / better.js

a better javascript in javascript
http://betterjs.org
MIT License
156 stars 22 forks source link

instanceof #98

Open icylace opened 10 years ago

icylace commented 10 years ago

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.

jeromeetienne commented 9 years ago

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

like

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