This might be simple to others but what's the data type of param1?
function name( {param1}, param2 ) {return;}
This might be simple to others but what's the data type of param1?
function name( {param1}, param2 ) {return;}
It is object destructuring
It is actually
function name( object1.param1, param2 ) {return;}
param1 is an property of an object. Above function could be rewrite as :
function name( object1, param2 ) {let param1 = object1.param1}
Refer: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
param2 could be anything
but definitely,
param 1 should be any object.
typeof({"dilshan"}) ----------------> Wrong
this will throw an error and you can not do this
typeof({"name":"dilshan"}) -----------> correct
this is valid one
then param1 should be an object :)