The code sample is here.
The big code chunk starts with
new function(settings) {
and ends with
}(jQuery.query || {}); // Pass in jQuery.query as settings object
What does this trick do?
Why does Eclipse find 2 errors here? Eclipse dislikes new at the beginning. May I just remove it? Also Eclipse wishes ] at the end to “to complete NewExpression”.
What does this mean? How to write this with []?
It is one way of creating a self-invoking javascript function. It’s simply a function that is declared and invoked in one swift flick of the wrist.
http://sparecycles.wordpress.com/2008/06/29/advanced-javascript/
What Eclipse is complaining about is not really clear. The syntax is completely valid – it might just be that Eclipse cannot handle it properly.
EDIT: The argument that is passed:
(jQuery.query || {})passes jQuery.query to the function. If jQuery.query is null, false, zero or undefineded (falsey), an empty object literal will be passed instead, avoiding a null reference.