Guest User

Untitled

a guest
Oct 22nd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. Object.prototype.forEach = function (f){
  2. var keys = Object.keys(this)
  3. keys.forEach(key => f(this[key],key,this))
  4. return this
  5. }
  6.  
  7. /*
  8.  
  9. let fruits = {apple: 3, orange: 4, banana: 8}
  10.  
  11. // Print each fruit
  12. fruits.forEach((count, fruit) => console.log("I have " + count + " " + fruit + "s")
  13.  
  14. // Increment each fruit by one
  15. fruits.forEach((count, fruit, o) => o[fruit] += 1)
  16.  
  17. */
Add Comment
Please, Sign In to add comment