difference between 'a' and 'instanceOf'

Viewed 136

I'm studying the Chai BDD API reference and I can't understand the difference between a and instanceOf.

Especially when I saw this example using a:

expect([1, 2, 3]).to.be.an('array')

And this one using instanceOf instead:

expect([1, 2]).to.be.an.instanceof(Array);

The documentation usually says something about Recommended or Not Recommended, but in this case I couldn't find anything. What I understood from the reference is that instanceOf can be used in case you have to check for an object constructor, whereas a is mainly used to checking types (is this right?). So, which is the most suitable with array?

0 Answers
Related