Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Object.prototype.forEach = function (f){
- var keys = Object.keys(this)
- keys.forEach(key => f(this[key],key,this))
- return this
- }
- /*
- let fruits = {apple: 3, orange: 4, banana: 8}
- // Print each fruit
- fruits.forEach((count, fruit) => console.log("I have " + count + " " + fruit + "s")
- // Increment each fruit by one
- fruits.forEach((count, fruit, o) => o[fruit] += 1)
- */
Add Comment
Please, Sign In to add comment