Search
 
SCRIPT & CODE EXAMPLE
 

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
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: gulp synchronous tasks 
Javascript :: Codewars JS Multiples of 3 or 5 
Javascript :: placeholder value js 
Javascript :: array reverse algorithm in js 
Javascript :: html button javascript void 
Javascript :: javascript function argument type 
Javascript :: how to find whether empty or not using jQuery 
Javascript :: how to check if an object is map in javascript 
Javascript :: Both npm and yarn have created lockfiles for this application, but only one can be used to install dependencies. 
Javascript :: javascript find all odd between two numbers 
Javascript :: checkbox change event javascript 
Javascript :: react native dimensions window vs screen 
Javascript :: Sending an Ajax request before form submit 
Javascript :: jquery window redirect with header 
Javascript :: jquery move element to another without losing events 
Javascript :: javascript how to check if element is visible on screen 
Javascript :: .call javascript 
Javascript :: how to add alternate image in img tag in react 
Javascript :: hide and show on button click in react js functional component 
Javascript :: how to remove duplicate values in array of objects using javascript 
Javascript :: installe datatable to reactjs project 
Javascript :: django jquery 
Javascript :: js text word wrap 
Javascript :: iframe content fetching 
Javascript :: jquery if .val is blank 
Javascript :: convert nodes to array javascript 
Javascript :: create react portal 
Javascript :: convert decimal to binary javascript 
Javascript :: javascript average of arguments 
Javascript :: onchange js 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =