If you have any questions please contact me by going to About Us
JavaScript is syntactically similar to many programming languages like C++ and Java. However, JavaScript programming is simpler in some ways.
For example, variables are declared with the keyword var. A variable is a named container that stores a value.
A variable does not have to be declared before being assigned a value.
A name created by a programmer for an item like a variable or function is called an identifier. JavaScript imposes the following rules for identifiers:
A JavaScript coding convention is to name JavaScript variables with camel casing, where the identifier starts with a lowercase letter, and subsequent words begin with a capital letter. Ex: lastPrice is preferred over LastPrice or last_price.
JavaScript uses the // and /* */ operators to produce comments in code, similar to C++ and Java. A comment is any text intended for humans that is ignored by the JavaScript interpreter. JavaScript does not require that statements be terminated with a semicolon. Only when two statements reside on the same line must a semicolon separate the two statements. Good practice is to avoid placing two statements on the same line. Some developers prefer to use semicolons at the end of statements, and others do not. Good practice is to consistently use semicolons or not throughout the code.
A JavaScript program may obtain text input from the user with the prompt() function. The prompt() function prompts the user with a dialog box that allows the user to type a single line of text and press OK or Cancel. The prompt() function returns the string the user typed or null if the user pressed Cancel. Output may be produced using the function console.log(), which displays text or numbers in the console. The console is a location where text output is displayed. Web browsers have a console (accessible from the brower's development tools) that displays output from code the browser executes. This chapter's activities display the console output in the web page.