I am doing a JavaScript course (specifically the MongoDB University M220JS course) and in one of the tasks I've come across this syntax for a function declaration inside a class:
static async getMovies({
filters = null,
page = 0,
moviesPerPage = 20,
} = {}) {
// some code, e.g.
console.log(moviesPerPage)
}
Where they've defined some JSON object and then written '= {}' inside the parameter list. The variables are then used inside the function (as I've shown) as if they've been declared like default parameters like so:
static async getMovies(filters = null, page = 0, moviesPerPage = 20) {
// some code, e.g.
console.log(moviesPerPage)
}
What does the syntax in the first example mean? What is the significance of the = {} part?