Skip to content

Instantly share code, notes, and snippets.

@fcgomes92
Created April 5, 2020 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fcgomes92/f0490c6a56cd7e71877fcd7f11b727a0 to your computer and use it in GitHub Desktop.
Save fcgomes92/f0490c6a56cd7e71877fcd7f11b727a0 to your computer and use it in GitHub Desktop.
some this reference for js
function GroceryList(items){
this.items = items;
this.mapItems = (fn) => {
let newItems = [];
// could use map but it would not fit for this example
for (let i = 0; i < this.items.length ; i++){
newItems = [...newItems, fn(this.items[i])];
}
this.items = newItems;
return this;
}
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment