Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Using an object of functions as a parameter into a function

function test({start, finish})
{

start();
finish();
}


function run()
{
	let obj = {start(){console.log("start");}, finish(){console.log('finish')}};
	test(obj);
}
/*test will console.log 'start' and 'finish'*/
/*Note in the above example the names of functions MUST MATCH. test({x, y}) would NOT have worked.*/
/*not recommended unless you know the names of the input functions ahead of time*/
Comment

PREVIOUS NEXT
Code Example
Javascript :: Inside Fetch Is A Request 
Javascript :: nested object data 
Javascript :: javascript hide div 
Javascript :: returning the outliers javascript array 
Javascript :: var logNums = function(num) {}; 
Javascript :: prisma bytes 
Javascript :: withrouter in react-router v6 
Javascript :: animation in react stack overflow 
Javascript :: useState intro 
Javascript :: Watch an API for Updates 
Javascript :: var maxNum = function(arr) {}; 
Javascript :: Backbone Model Most Simple 
Javascript :: Backbone + Express 
Javascript :: Using Fetched Data With Backbone 
Javascript :: Backbone View Notes 
Javascript :: react native long form keyboard awaire 
Javascript :: react native componentdidmount in function 
Javascript :: how to check the validation of time in react datetime 
Javascript :: use of prototype in javascript 
Javascript :: javascript interview questions interviewbit 
Javascript :: sort list in javascript 
Javascript :: looping object 
Javascript :: js pow function 
Javascript :: search query in javascript 
Javascript :: how to run react app on apache server 
Javascript :: expo create react native app command 
Javascript :: javascript Access Set Elements 
Javascript :: JavaScript Comparison and Logical Operators 
Javascript :: json syntax 
Javascript :: switch javascript to java 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =