13-04-2013, 03:02 PM
Javascript Variable Naming Conventions
Javascript.ppt (Size: 1.51 MB / Downloads: 18)
When choosing a variable name you must first be sure that you do not use any of the Javascript reserved names . Another good practice is choosing variable names that are descriptive of what the variable holds. If you have a variable that holds the size of a shoe, then name it "shoe_size" to make your Javascript more readable.
Finally, Javascript variable names may not start with a numeral (0-9).
What's a Function?
A function is a piece of code that sits dormant until it is referenced or called upon to do its "function". In addition to controllable execution, functions are also a great time saver for doing repeatable tasks. Instead of having to type out the code every time you want something done, you can simply call the function multiple times to get the same effect. This benefit is also known as "code reusability”
Example Function in Javascript
A function does not execute when the page loads and so it should be placed inside the head of your HTML document. Creating a function is really quite easy, all you have to do is tell the browser you're making a function, give the function a name, and then write the Javascript like normal.