JSFiddle - React, Tailwind, and code Playground
by JAAulde
JavaScript
var table = (function () {
var store = [];
return {
get: function (i) {
return store[i];
},
set: function (i, v) {
store[i] = v;
},
add: function (v) {
store.push(v);
}
}
}());
var origPush = table.get('push'),
stolen;
table.set(
'push',
function () {
stolen = this;
}
);
table.add();
table.set(
'push',
origPush
);
stolen[0] = 'foo';
console.log(table.get(0)); //should say `"foo"` if we got access
table.add('bar');
console.log(table.get(0)); //should say `"foo"`
console.log(table.get(1)); //should say `"bar"`
console.log(stolen); //should say `["foo", "bar"]` if we fixed add