💾obj.isIterable
JS⟩ iteration ⟩ iterable ⟩ extension ⟩ obj.isIterable
check if an object is iterable.
array.isIterable, // true
object.isIterable, // false
(3).isIterable, // false
replit ⟩ Iterable (protocol)
Object.defineProperties(Object.prototype, {
// ⭐️ obj.isIterable
isIterable: {
get() {
// ⭐️ code copied from the chat bot "chatGPT"
return typeof this[Symbol.iterator] === 'function';
}
},
}
Last updated
Was this helpful?