How to call a function using object with the parameter names and values in JavaScript

1 Answer

0 votes
const func = ({id = 87321, name = 'Angelina', city}) => {
    document.write(id + " : " + name + ' : ' + city + '<br />');
};

const args = { id: 994372, name: 'Tom', city: 'New York' };
func(args);




/*
run:
          
994372 : Tom : New York
    
*/

 



answered Nov 7, 2019 by avibootz
...