I have come across the following jQuery code but could not understand it. What does the following code, specially the “$([])” part in the last line mean ?
var instrument = $("#instrument"),
quantity = $("#quantity"),
orderType = $("#orderType"),
price = $("#price"),
validityDate = $("#validityDate"),
allFields = $([]).add(instrument).add(quantity).add(orderType).add(price).add(validityDate)
Looks like it’s defining an array, then add()ing the DOM elements to it. From the manual:
[]is an empty javascript array. As frunsi notes, this is not correct usage, and the[]definition is not required to create an empty set of elements, in 1.4$()will do ths for you.