Last active
February 23, 2018 15:46
-
-
Save enricopolanski/d51192fbd00a34a96e2f757988299600 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
userPlan = { | |
// plenty of stuff | |
startingWeek = Date object; // such as Mon Feb 19 2018 16:34:08 GMT+0100 (W. Europe Stand… | |
// other stuff | |
} | |
function saveData(data){ | |
console.log(this) // => correctly logs the userPlan object, including startingWeek property | |
console.log(this.data) // logs 'undefined' | |
localStorage.setItem(data, JSON.stringify(this.data)); // => saves: 'startingWeek' : undefined; | |
} | |
saveData.call(userPlan, 'startingWeek'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment