Set default paramater through empty object in moviesDAO.js

I was working on the Paging ticket and I noticed that in the moviesDAO.js function of getMovies() is passed an object…

getMovies( {filter = null, page = 0, moviesPerPage = 20 } = {} )

This apparently allows anyone calling getMovies() to pass in an object and set page, filter, or moviesPerPage, and if any parameters aren’t set, it gets defaulted to the above values. Also, in addition, the parameters can be accessed simply by calling the parameter name without actually specifying an object name.

Can someone explain how this works, whether it’s a pre-processor that’s handling this? Thanks!

This is standard JavaScript.

Thanks. I realized in my sleep that this was probably object destructuring. I just didn’t know you can pass the values as a parameter like this to set default values.