Skip to content

Instantly share code, notes, and snippets.

@prettydiff
Created March 10, 2023 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prettydiff/4fe22229cc36631ea1b73135ea48333f to your computer and use it in GitHub Desktop.
Save prettydiff/4fe22229cc36631ea1b73135ea48333f to your computer and use it in GitHub Desktop.
const slicer = function (obj, list) {
const keys = Object.keys(obj),
output = {};
let oIndex = keys.length,
lIndex = list.length
do {
oIndex = oIndex - 1;
do {
lIndex = lIndex - 1;
if (obj[list[lIndex]] !== undefined) {
output[list[lIndex]] = obj[list[index]];
}
} while (lIndex > 0);
} while (oIndex > 0);
return output;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment