Be careful when using instanceof

If you intend to throw an error if an object is not an instanof a specific object, be careful of this mistake that's easy to make.

 

if( !someVar instanceof SomeObject){  //WRONG!
throw new Error("....");
}

 If someVar is null or undefined then your error will not be thrown.

 

This is better:

 

if( !(someVar instanceof SomeObject)){  
throw new Error("....");
}

 

 

 

 

 

Add a Comment...

 

Comments

mattresses 2017 the best rated mattress 2017 top rated mattresses for 2017 best rated mattress for 2017 best time to buy mattress 2017 best mattresses 2017 for couples best mattresses to buy online 2017 top 10 mattresses 2017 best mattresses 2017 the best mattress of 2017 best rated mattress for 2017 best mattress of 2017 for side sleeper consumer reports best mattress 2017 consumer reports best mattress 2017 best mattresses 2017 casper coupon codes printable casper coupon casper disco - 7/22/2017

Revolutional update of SEO/SMM software "XRumer 16.0 + XEvil 3.0": captcha breaking of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex, and more than 8400 another subtypes of captcha, with highest precision (80..100%) and highest speed (100 img per second). You can connect XEvil 3.0 to all most popular SEO/SMM programms: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other software. Interested? You can find a lot of impessive videos about XEvil in YouTube. - 7/22/2017

Absolutely NEW update of SEO/SMM software "XRumer 16.0 + XEvil 3.0": captchas regignizing of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex, and more than 8400 another types of captcha, with highest precision (80..100%) and highest speed (100 img per second). You can connect XEvil 3.0 to all most popular SEO/SMM programms: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other programms. Interested? You can find a lot of introducing videos about XEvil in Yo - 7/22/2017

Absolutely NEW update of SEO/SMM software "XRumer 16.0 + XEvil": captcha breaking of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex, and more than 8400 another subtypes of captchas, with highest precision (80..100%) and highest speed (100 img per second). You can connect XEvil 3.0 to all most popular SEO/SMM software: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other programms. Interested? There are a lot of introducing videos about XEvil in YouTube. - 7/22/2017

Revolutional update of SEO/SMM package "XRumer 16.0 + XEvil 3.0": captchas recognition of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex, and more than 8400 another size-types of captcha, with highest precision (80..100%) and highest speed (100 img per second). You can connect XEvil 3.0 to all most popular SEO/SMM software: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other software. Interested? You can find a lot of demo videos about XEvil in YouTube. - 7/21/2017

Revolutional update of SEO/SMM package "XRumer 16.0 + XEvil 3.0": captcha recognition of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex, and more than 8400 another categories of captchas, with highest precision (80..100%) and highest speed (100 img per second). You can connect XEvil 3.0 to all most popular SEO/SMM software: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other programms. Interested? There are a lot of impessive videos about XEvil in YouTub - 7/18/2017

Absolutely NEW update of SEO/SMM software "XRumer 16.0 + XEvil": captchas solution of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex, and more than 8400 another size-types of captcha, with highest precision (80..100%) and highest speed (100 img per second). You can connect XEvil 3.0 to all most popular SEO/SMM programms: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other programms. Interested? There are a lot of impessive videos about XEvil in YouTube. - 7/17/2017

Revolutional update of SEO/SMM package "XRumer 16.0 + XEvil": captcha solution of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex, and more than 8400 another types of captchas, with highest precision (80..100%) and highest speed (100 img per second). You can connect XEvil 3.0 to all most popular SEO/SMM software: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other software. Interested? There are a lot of impessive videos about XEvil in YouTube. Good luc - 7/14/2017

Article writing is also a excitement, if you be familiar with afterward you can write or else it is complex to write. liverpool tröja - 5/16/2017

vbex kotorisha bluechat mitratraderindonesia montreallanguage prugna mecawear ww2 newportucc sizlar - 5/08/2017

Awesome site you have here but I was curious about if you knew of any community forums that cover the same topics discussed in this article? I'd really love to be a part of community where I can get suggestions from other experienced individuals that share the same interest. If you have any recommendations, please let me know. Many thanks! fotbollströjor - 4/26/2017

Braydenfu BVB Borussia Dortmund MikkiSpiv ArielleHo West Ham United NathanCar Christian Chelsea WNRShelli MalloryBr Danmark KrystalEd Valeriaaq Colombia SherrillD SammyBrac Danmark KenCouvre KeenanChi Roma Nildakqag GonzaloGo Rumanien FelipaHac FredricRa Turkiet FelixBril WyattBive Polen CletaHild - 3/07/2017