'use strict'; const any = (arr) => { for (let value of arr) { if (value) { return true; } } return false; }; console.log(any([false, false, false])); console.log(any([false, true, false])); //=> false //=> true const object = {foo: [false, false, false], bar: [false, false, true]}; for (let key in object) { console.log(key); console.log(object[key]); } //=> foo //=> [ false, false, false ] //=> bar //=> [ false, false, true ]
- 配列は for...of
- オブジェクトは for...in