Created
April 5, 2020 15:21
-
-
Save smokinggoats/f0490c6a56cd7e71877fcd7f11b727a0 to your computer and use it in GitHub Desktop.
some this reference for js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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