Skip to content

Instantly share code, notes, and snippets.

@smokinggoats
Created April 5, 2020 15:21
Show Gist options
  • Save smokinggoats/f0490c6a56cd7e71877fcd7f11b727a0 to your computer and use it in GitHub Desktop.
Save smokinggoats/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