Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:40

semi-colon consistency

Poster: mjanke
Dated: Sunday June 26 2005 - 15:20:18 BST

In this sample line of menu_data.js...

aI("text=some text;url=http://a url goes here;")

Should there be a semi-colon after the closing parenthesis or not? Even the sample menus included are inconsistent in this regard. Some have a semi-colon at the very end after that parenthesis, some don't.

Seems to work either way, but I don't want any surprises.

Poster: Ruth
Dated: Sunday June 26 2005 - 20:05:48 BST

I'm not up on when you 'can' and when you 'must' use a semi-colon in js, however, I would suggest, since the majority of them have semi-colons, that you use them after the closing bracket of an aI string. I do since that is how they all were in the beginning and I know that they work that way in all the browsers I tested. As you said, I have no surprises that way ;)


Poster: Andy
Dated: Monday June 27 2005 - 11:17:25 BST


With JavaScript the semi-colon is not mandatory, that's why sometimes it's there sometimes not.

However, the semi-colon does indicate end of code line so if you wanted to put your code on one line, you would need to semi-colon.

So this:

var a=10
var b=123

Is the same as

var a=10;var b=123

Hope this helps,

Poster: Ruth
Dated: Monday June 27 2005 - 13:57:36 BST

Thanks, Andy :D


Poster: Andy
Dated: Monday June 27 2005 - 14:10:11 BST

Thanks, Andy

No worries, also note that scripts like Perl and PHP DO need the quotes, otherwise you get a runtime error.

Useful for when you start coding some awesome stuff in PHP. Also, the syntax of PHP is very similar to that of JavaScript - It's all based on the C programming language.

Oh, and somebody asked why variable names have lower case and upper case mixes.

Well, the technical terms for this is camelCase - I use it because it looks a lot neater than camel_case but it's all personal preference.

Here's something about programing in C#:

There's a .net framework recommendation that relates to the accessibility of class members.

1. Identifiers that are public should start with a capital letter. For example, Area starts with A and not a because it's public. This system is known as PascalCase (another programming language) naming scheme.

2. Identifiers that are not public (which include local variables) should start with a lowercase letter. For example, radius starts with r, not R bacause it's private. This is know as camelCase.

It's not that important in JavaScript so everything is in camelCase to make life easier.

Hope I havn't confused you too much,

Poster: John
Dated: Monday June 27 2005 - 16:07:20 BST

Just to add to the mix from the guy lurking out in left field, while not mandatory, as Andy said, we'd really like to see (taking from your example)...
aI("text=some text;url=http://a url goes here;");
aI("text=some more text;url=http://another url goes here;");

...simply for consistency.

Poster: mjanke
Dated: Tuesday June 28 2005 - 1:22:32 BST

Thanks, everyone. I'll stick with closing semi-colons on all lines for consistency.