Why Nostr? What is Njump?
2024-06-08 04:33:04

🍄🌈🎮💻🚲🥓🎃💀🏴🛻🇺🇸 on Nostr: Say you have a big object but you are just interested in a handful of it's ...

Say you have a big object but you are just interested in a handful of it's properties; you could go:

var {foo, bar} = bigObject;
var smallObject = {foo, bar};

but if there's a lot of properties this could get verbose as you have to keep adding property names twice.

is there "clean" way to do this? like:

var smallObject = ['foo', 'bar'].reduce((_, p) => _[p] = bigObject[p], {} );

#webDev #javaScript #programming
Author Public Key
npub1j5203u6ym5cf89h0xm4feezxxvt9cf6jcdwtn3fvq9zw4rs54rqq6cjsn5