Skip to content

Instantly share code, notes, and snippets.

@MananTank
MananTank / array-to-map.js
Created October 3, 2021 11:33
Fastest way to convert Array to Map
const map = new Map()
for (let i=0; i<array.length; i++) {
map.set(array[i], i)
}
@MananTank
MananTank / superArray.js
Created September 8, 2020 16:39
create arrays with super powers, with negative indexing and range support.
// code to create arrays with super powers !
const superArray = (initArray) => {
const toPos = (index, target) => {
const _index = Number(index);
return index < 0 ? target.length + _index : _index;
};
return new Proxy(initArray, {
get(target, prop) {