JSFiddle - React, Tailwind, and code Playground
by joplomacedo
JavaScript
function extractNonPrivateKeys( obj ) {
const result = {
...obj
};
for ( let key in result ) {
if (result.hasOwnProperty(key)) {
if ( key.indexOf('_') == 0 ) {
delete result[key];
}
}
}
return result;
}
const res = extractNonPrivateKeys({
a: 3,
b: 5,
_a:2,
_private: 3213,
PUBLIC: 2
})
console.log(res);