Last updated 2 years ago
Was this helpful?
⟩ ⟩ ⟩ ⟩ ⟩ Object+arrayLike
extend objects with custom methods.
TouchList+ext - TouchList is an .
replit:
// 2023.01.17 - 07:57 - first draft // -------------------------------------------------- // helpers function checkType(obj) { if (!('length' in obj)) { throw Error(`${obj} is not an "array-like" object!`) } } // ⭐️ Object + array-like // -------------------------------------------------- // 🔹 .map() // Object.defineProperties(Object.prototype, { // 🔹 .map() map: { value: function(f) { checkType(this); const arr = []; for (let i = 0; i < this.length; i++) { arr.push(f(this[i])); } return arr; } }, }); // export // ------------------------------------------- export {}; // ES module // module.exports = {}; // CommonJS module