[].every(i => i instanceof Node) // -> true
Why does the every method on arrays in JavaScript return true when the array is empty. I'm trying to do type assertion like so...
const isT = (val, str) => typeof val === str
const nT = (val, str) => !isT(val, str)
const is = {}
is.Undef = (...args) => args.every(o => isT(o, 'undefined'))
is.Def = (...args) => args.every(o => nT(o, 'undefined'))
is.Null = (...args) => args.every(o => o === null)
is.Node = (...args) => args.every(o => o instanceof Node)
is.NodeList = (...args) => args.every(n => n instanceof NodeList)
but these still return true even when no arguments are passed to them.
is.Undef = (...args) => args.length && args.every(o => isT(o,'undefined'));– synthet1c Dec 7 '15 at 15:32