Checking instance type with instanceOf

There are many situations, such as argument validation, where we'll want to check the class of an object. Because JavaScript is not statically typed, we can't guarantee that a function receives an argument of the correct type before the program starts, and we need to check at runtime.

In this recipe, we'll see how to use the instanceOf operator to check an object's prototype at runtime.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.214.32