0

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?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.