[].every(i => i instanceof Node)
Why does each array method in JavaScript return true when the array is empty. I'm trying to make a type statement like this ...
let isT = (val, str) => typeof val === str, is = {}, nT = (val, str) => !isT(val, str); 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) => Array.from(args).every(n => is.Node(n));
but they still return to the truth, even when no arguments are passed to them.
source share