Skip to content

Instantly share code, notes, and snippets.

@iampava
Last active June 8, 2021 02:34
Show Gist options
  • Save iampava/b1d7e39d394f48a41ce10f6338dc988a to your computer and use it in GitHub Desktop.
Save iampava/b1d7e39d394f48a41ce10f6338dc988a to your computer and use it in GitHub Desktop.
Hacking Javascript |
function PiggyBank(){
let money = [];
return {
store: function(index, value){
money[index] = value;
},
push: function(value){
money.push(value);
}
}
}
let sharedPiggyBank = PiggyBank();
// Mom gives the sharedPiggyBank to Bob & Alice
// But, there's a weakness in this code which allows direct access to the money Array.
// Can you spot it?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment