1

I found next form of new operator in the less documentation.

var parser = new (less.Parser) ({
    pathes [
        '.',
        './css'
    ],
    filename: 'style.less'
});

What the differences from the usual form?

var parser = new less.Parser({
    patches [
        '.',
        './css'
    ],
    filename: 'style.less'
});

Can it be combined with .apply method?

alex_ac
  • 121
  • 8

1 Answers1

4

There's no difference between

var parser = new (less.Parser) (...);

and

var parser = new less.Parser (...);

The parens around less.Parser are entirely superfluous.

Can it be combined with .apply method?

It's difficult to use a function designed to be called via new (a "constructor function") via apply, because new does a lot of things. (This is true of both forms of the above, since — again — they're the same thing.) I talk about using apply with constructor functions more in this other answer here on Stack Overflow.

Community
  • 1
  • 1
T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875