Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
};
 
PREVIOUS NEXT
Tagged: #js #function #pick #properties #object
ADD COMMENT
Topic
Name
9+8 =