I'm new to Javascript and thus this question, I understand arrow functions. However this syntax completely confuses me. This is an implementation of a PriorityQueue which takes a function comparator as a callback, this is the syntax,
class PriorityQueue {
constructor({ comparator = (a, b) => a - b, initialValues = [] } = {}) {
this.comparator = comparator;
this.data = initialValues;
this.heapify();
}
I don't understand what this line means,
{ comparator = (a, b) => a - b, initialValues = [] } = {}
The complete code is here, should you need it, https://github.com/jeantimex/javascript-problems-and-solutions/blob/master/src/common/priority-queue.js
But can someone please help me understand that line of code. Thanks in anticipation.