views:

66

answers:

3
allFields = $([]).add(name).add(email).add(password)

$([]) ??

A: 

looks like it's creating an array and adding name, email, and password into it.

in javascript [] is just an empty array.

John Boker
A: 

I believe that creates a jQuery Object with nothing selected inside it. Generally you pass a selector to jQuery to select page elements, and then preform actions on them.

$('.myElements');

Instead, this just creates a jQuery Object that has nothing selected, which you can then use jQuery functions to add stuff to it.

$([]);

It then uses the add function to populate the object with certain selectors.

See the add() function.

Chacha102
A: 

From the jquery docs http://api.jquery.com/jQuery/#jQuery1

jQuery( elementArray )

elementArrayAn array containing a set of DOM elements to wrap in a jQuery object.

In this case, the selected array is initially empty.

Lachlan Roche