Variable initialization with curly braces

N

Nick S

I've just been trying to de-construct the jQuery tooltop plugin in an
attempt to better my javascript coding and I've come across a question
google can't help me with.

What is the deal with initializing a variable like this?

var helper = {},
// the current tooltipped element
current,
// the title of the current element, used for restoring
title,
// timeout id for delayed tooltips
tID,
// IE 5.5 or 6
IE = $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent),
// flag for mouse tracking
track = false;

What are the first curly braces?

Thanks
 
L

Lasse Reichstein Nielsen

Nick S said:
What is the deal with initializing a variable like this?

var helper = {},

This declares the "helper" variable and assigns it a value that is
a new object.

...
What are the first curly braces?

The expression "{}" is an object literal expression that evaluates to
a new object with no extra properties. It's equivalent to
"new Object()".

/L
 
N

Nick S

This declares the "helper" variable and assigns it a value that is
a new object.

..


The expression "{}" is an object literal expression that evaluates to
a new object with no extra properties. It's equivalent to
"new Object()".

/L

Thanks to everyone for your answers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top