I have a JS object that i want to log to the console but one of its values is 5 million characters of a hashed image so im not really interessted in that. Is there a way to exclude this key from the console log / is there a short form for cloning the object, deleting the value and logging it?
Not a duplicate of "cloning object except for one key" btw
function logObjectWithoutKey(key, obj) { const { [ key ]: suppressed, ...rest } = obj; console.log(rest); }... and then e.g ...logObjectWithoutKey('img', { foo: 'foo', bar: 'bar', baz: 'baz', img: 'a lot of data' });... or ...logObjectWithoutKey('baz', { foo: 'foo', bar: 'bar', baz: 'baz', img: 'a lot of data' });