Answers for "js function pick properties from object"

1

js function pick properties from object

function pick (obj: { [key: string]: any }, props: string[] | string) {
	const propsArray = Array.isArray(props) ? props : props.split(' ')
	var picked: {
    	[key: string]: any
    } = {};
  
	propsArray.forEach(function(prop) {
		picked[prop] = obj[prop];
	});
  
	return picked
};
Posted by: Guest on January-23-2021
2

js select keys from object

const object = { a: 5, b: 6, c: 7  };
const picked = (({ a, c }) => ({ a, c }))(object);

console.log(picked); // { a: 5, c: 7 }
Posted by: Guest on September-04-2020
0

javascript object get subset

const object = { a: 5, b: 6, c: 7  };const subset = (({ a, c }) => ({ a, c }))(object);console.log(subset); // { a: 5, c: 7 }
Posted by: Guest on May-12-2020

Code answers related to "js function pick properties from object"

Code answers related to "Javascript"

Browse Popular Code Answers by Language