473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Complex Variable

I was advised by someone in the Google Maps API group to use this
method of assigning values to a variable:

var test = {
colour:"red",
sound:"music",
smell:"perfume"
};
alert(test.sound);

This works really well but I cannot find any information regarding how
this works.

Could someone enlighten me regarding this method of assigning values
to a variable, ie what is the meaning of the ":" and why is no comma
required after the last line etc.

Cheers

Oct 9 '07 #1
4 2360
On Oct 9, 12:32 pm, Steve <stephen.jo...@googlemail.comwrote:
Could someone enlighten me regarding this method of
assigning values to a variable
http://developer.mozilla.org/en/docs...bject_Literals
ie what is the meaning of the ":"
Assignment of a value to a property
and why is no comma
required after the last line etc.
Its forbidden, IIRC, not simply 'not required'. Its a separator not a
terminator (so it goes between property/value pairs, not after them).

--
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/

Oct 9 '07 #2
That helps, many thanks.
On Oct 9, 4:24 pm, David Dorward <dorw...@gmail.comwrote:
On Oct 9, 12:32 pm, Steve <stephen.jo...@googlemail.comwrote:
Could someone enlighten me regarding this method of
assigning values to a variable

http://developer.mozilla.org/en/docs...5_Guide:Litera...
ie what is the meaning of the ":"

Assignment of a value to a property
and why is no comma
required after the last line etc.

Its forbidden, IIRC, not simply 'not required'. Its a separator not a
terminator (so it goes between property/value pairs, not after them).

--
David Dorwardhttp://dorward.me.uk/http://blog.dorward.me.uk/

Oct 9 '07 #3
David Dorward wrote:
On Oct 9, 12:32 pm, Steve <stephen.jo...@googlemail.comwrote:
>[Object initializer]
and why is no comma required after the last line etc.

Its forbidden, IIRC, not simply 'not required'.
It's not forbidden. The specification does not define the mechanism
explicitly, but it includes the provision for conforming implementations
to deviate from the specified program syntax (section "2 Conformance").

It is unwise to write the comma there because ECMAScript implementations
(particularly JavaScript and JScript) differ here; that is not an issue when
the used implementation is known (say in a Firefox extension).
Its a separator not a terminator
Correct.
(so it goes between property/value pairs, not after them).
In JavaScript 1.5 (in contrast to JScript),

var foo = {bar: "baz",};

is semantically equal to

var bla = {foo: "baz"};

It will show a warning in Geckos, though:

| Warning: trailing comma is not legal in ECMA-262 object initializers
| Source file: javascript: var foo = {bar: "baz",};
| Line: 1, Column: 23
| Source code:
| var foo = {bar: "baz",};
PointedEars
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Oct 9 '07 #4
Thomas 'PointedEars' Lahn wrote:
In JavaScript 1.5 (in contrast to JScript),

var foo = {bar: "baz",};

is semantically equal to
var foo = {bar: "baz"};
Oct 9 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ken in Melbourne Australia | last post by:
If I use the curly bracket syntax (referred to as the complex syntax) within a string, how do I get to call a function within it? The php manual says that the first (or previous) character for...
0
by: olafmol | last post by:
Hello, i have a problem using a .NET WSDL Webservice from PHP. Using both the NuSOAP lib for PHP4, and the build-in SOAP lib for PHP5 it seems that the SOAP client cannot pass a variable amount...
9
by: Protoman | last post by:
I'm trying to print a complex number and i get this as output: Phi: (1.618034,0.000000). What does it mean? How do I get it to print normally? Here's the code: ----------fib.hpp-------------...
4
by: Gerald I. evenden | last post by:
I have found that with the Gnu compiler that undocumented output of a "double comple" value can be successfully performed by: double complex v; printf("%g %gi\n",v); which will print the...
4
by: Mantorok Redgormor | last post by:
With what specifier do I use to print a variable of a complex type? The man page for printf doesn't even say. - nethlek
4
by: Carl-Olof Almbladh | last post by:
Dear all, In C99, complex is now built in, and the C library contains functions for complex exp, etc. It is not so easy to find info about the syntax if one is not willing to buy the ISO/ANSI...
3
by: Klaas Vantournhout | last post by:
Hi, I am using CLAPACK to do lots of matrix operations, but this is done on complex matrices. There I also need to work with normal complex operators, I use also the standard complex library. ...
7
by: Tina | last post by:
Dear all, I'm looking for a routine which calculates the Gamma Function for a complex valued variable. I'm using #include <complex> to work with complex numbers. I define a complex number...
1
by: koehlerc14 | last post by:
So here is the deal, I am attempting to make what is the most complex form i have made yet. It really is not much, but as an amatuer it is a little overwhelming. Here's a few critical background...
9
by: void main | last post by:
I'm rather new to complex numbers in C and was wondering, how do I initialize a complex variable properly if the imaginary part is 0. I tried -------- #include <complex.h> float complex c...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.