0

This might be simple to others but what's the data type of param1?

function name( {param1}, param2 ) {return;}
Jaan
  • 1
  • I think it's JSON Object – Hkachhia Feb 10 '21 at 12:44
  • @Hkachhia [There's no such thing as a "JSON Object"](http://benalman.com/news/2010/03/theres-no-such-thing-as-a-json/) | [What is the difference between JSON and Object Literal Notation?](https://stackoverflow.com/q/2904131) – VLAZ Feb 10 '21 at 12:46
  • Please provide much more context here, it can be understood in many different ways. – magmel Feb 10 '21 at 12:51

2 Answers2

0

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

0
  • considering param1 and param2,

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 :)