Dumb question from a noob

While learning Javascript I haven’t fully understood when and where to put:

parenthesis ( )
Commas ,
periods .
Colons :

If anybody could help clarify this for me it would help me a lot with the learning process!

If you’re all new to programming and object orientation, it is a lot to take in. Following a guide is probably the best thing to do:

http://forum.unity3d.com/threads/34015-Newbie-guide-to-Unity-Javascript-(long)

Buying a book is also a good thing.

Just staring at code and trying to understand it without prior knowledge is not an efficient way of learning. :slight_smile:

Thanks for your response. I’ve checked that that guys info before, a lot of good stuff there. I’m getting a good grasp on variables, functions, arrays and so on. But of all the tutorials I’ve watched, and forums I’ve gone through I haven’t came across one that explains why the’re using the commas, parentheses, or periods and so on…

Good tip on the book. It’s Saturday night, looks like its time for another drunken trip to the book store!!!

Hey Alec,

For the punctuation, in a general sense, you have to keep in mind what actually happens when code is compiled. Another computer programming is going through your code, breaking it into chunks, and expanding it into more instructions. The different pieces of syntax (comma, period, etc.) tell the compiler how to parse your code.

As an example:
myFunction(var1, var2)

A comma is used to tell the compiler how to separate two variables in a function. Without the comma, the compiler wouldn’t be able to tell there are two variables. Unfortunately, pieces of punctuation often have multiple uses, and the only way I know of learning them is experience.

As to specifically ‘Why do they use a comma for this purpose instead of any other piece of punctuation, like an exclamation point?’ It’s because that’s how the C syntax is structured, and JS gets a lot of its syntax from C. Now, ‘Why did they do it that way in C?’ I have no idea, probably just picked them at random :wink:

Thanks man that’s a big help. I pick up 3D software pretty easily but this js is a whole other beast. I hope one day I’ll be able to type up code as easily as I can type an essay. That again :smile: