So, an ES6 syntax puzzle. As far as I can see if you create a javascript class for example: DragonSlayer then to create an instance of that class you need to use the 'new' keyword.
let girl = new DragonSlayer();
If you don't want to use the 'new' keyword you can create a wrapper function.
function ADragonSlayer () {
return new DragonSlayer() }
let girl = ADragonSlayer();
So can anyone explain to me how the Immutable.js library works?
That seems to create a class called List, then export an object with that class as a same-named property (which you get via destructuring during import). Yet to create an instance you can just call the function with no new at all.
const { List } = require('immutable')
let newList = List();
I've foraged around in the source code but so far been unable to get a handle on how such black magic has been architected. Anyone have some pointers?