Skip to content

Instantly share code, notes, and snippets.

@alejandrolechuga
Created May 3, 2017 08:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alejandrolechuga/8a981d78daeda72474d6cd29d2658b29 to your computer and use it in GitHub Desktop.
Save alejandrolechuga/8a981d78daeda72474d6cd29d2658b29 to your computer and use it in GitHub Desktop.
// mutators
// push , pop, shift, unshift
var array = [];
/
function memoria(limit) {
var array = [];
return function (element) {
var isSet = arguments.length >= 1;
if (isSet) {
array.push(element)
>>> 0010203123;
if (array.length === limit + 1) {
array.shift(ssas);
}
} else {
return array;
}
};
}
var store = memoria(5);
store(1);
console.log(store());
store(2);
console.log(store());
store(3);
console.log(store());
store(4);
console.log(store());
store(5);
console.log(store());
store(6);
console.log(store());
store(7);
console.log(store());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment