By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,599 Members | 1,872 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,599 IT Pros & Developers. It's quick & easy.

label: function() { etc.... } syntax

P: n/a
Hi,
I've found this syntax in a script from rico, but I don't understand
what do the ":" mean.
This is the snippet of code where I've found it:

var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
}

Is create simply a label, or does it give tha name to the function?
Any comment is appreciated.
Thank you
Bye!
--
elimina carraro per rispondere via email
Oct 11 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a


Generale Cluster wrote:

var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
}

Is create simply a label, or does it give tha name to the function?


On the right side of the assigment is an object literal (also called
object initializer) which is enclosed in curly braces {} and then
defines the properties of the object in the form
propertyname : propertyvalue
In that example there is one property with the name create and the value
being constructed from a function expression.

See
<http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Literals#Object_Literals >
for an introduction and bookmark
<http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide> to
perhaps find answers to further questions yourself.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.