Derek Hogan
Derek Hogan

Reputation: 35

jQuery variable assignment confusion

I just ran into a jQuery code example which confuses me a bit.

var $tasks = $('#task_list'), i;

This was used to get the ul element from the DOM and store it in the $tasks variable.

But why the i at the end?

Upvotes: 0

Views: 128

Answers (1)

David Hellsing
David Hellsing

Reputation: 108500

This is exactly the same as:

var $tasks = $('#task_list');
var i;

It’s just a different syntax using commas between var statements.

You can read more about the var statement and peek at more advanced examples here: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Statements/var

Upvotes: 6

Related Questions