mutant
mutant copied to clipboard
Array().length == 1?
It seems that
let a = Array()
console.log(a.length)
= 1, but:
let a2 = []
console.log(a2.length)
= 0
This is a bit of a gotcha :)
Indeed. This is one of the many unfortunate consequences of using function
as the base for all the observables.
Here is an idea to improve the situation by making only the simple types based on function and moving the complex (collections, structs, etc) to ordinary objects: https://github.com/mmckegg/mutant/issues/8#issuecomment-320532689
We’d also change isObservable
to use Symbols for detection instead of typeof x === ‘function’
.
Great! I'm all for removing gotcha's. This is very much related to the documentation part of scuttlebot. While developing something for patchcore I changed my tactics to highlightning pain points I find as I move through them, hopefully we can all learn something :)