JS: What do curly braces mean within function parameter declarations?

I followed this React with Redux configuration tutorial and I noticed some syntax that I am not familiar with. What are the braces inside the function parameter definition?

Example:

function Stream({ tracks = [], onAuth }) { #what is going on here? return ( <div> ... #component stuff here </div> ); } 

Is this answer specific? Or does this have anything to do with Babylon or some other library? I am new to this technology, so I’m not sure what is going on.

+5
source share
1 answer

It is similar to the destructuring syntax, but I did not know that javascript had a destructuring.

If this is what it is, the function expects an object with a tracks field (but can by default an empty list if the object does not have it) and an onAuth field, which by default will be undefined . This is basically an easier way to access the fields of the passed object.

+5
source

All Articles