Closed bahamas10 closed 9 years ago
This implementation has been deemed too strict... based on a convo with me + @pfmooney
@pfmooney
3:02 > Array.prototype.specialFunc = function () { console.log('omg'); };
[Function]
> bar = new Array()
[]
> bar.specialFunc();
omg
undefined
@pfmooney
2:57 I think o.constructor == Object might be dangerous
2:58 we can't be that strict
2:59 > function Foo() { }
undefined
> var bar = new Foo();
undefined
> bar
{}
> bar.constructor
[Function: Foo]
2:59 assert.object(bar) should absolutely succeed
The solution right now is to just bail if o
=== null
Fixed in v0.2.0
Right now,
.object()
only checkstypeof (...) === 'object'
. While this makes sense, it allows for a lot of things to pass that check that, while are objects, we might not consider to be objects as such.For example:
All pass the test.
null
and[]
are the most egregious, though everything listed above are technically javascript objects. Would a modification to.object
to be stricter make sense? or maybe the addition of a.strictObject
?ex: