language, developed by Netscape in 1995 • JavaScript is a scripting language. It is a lightweight, • JavaScript is a scripting language. It is a lightweight, but powerful, programming language. • JavaScript similarities to Java/C++ • JavaScript is Client-side web programming • JavaScript is the most popular programming language in the world.
between <script> and </script> tags. • • JavaScripts can be put in the <body> and in the <head> section of an HTML page. • Two Ways to Insert JavaScript: 1. Internal script 2. External script sheet
external files. • • External scripts are practical when the same code is used in many different web pages. • JavaScript files have the file extension .js. • To use an external script, put the name of the script file in the source (src) attribute of the <script> tag
case sensitive. • The variables lastName and lastname, are two different variables. • The functions myFunction and myfunction, are two different functions. • JavaScript does not interpret Var; as var.
statements: statements: 1. Use if to specify a block of code to be executed, if a specified condition is true 2. Use else to specify a block of code to be executed, if the same condition is false 3. Use else if to specify a new condition to test, if the first condition is false 4. Use switch to specify many alternative blocks of code to be executed
for - loops through a block of code a number of times 2. for/in - loops through the properties of an object 3. while - loops through a block of code while a specified condition is true 4. do/while - also loops through a block of code while a specified condition is true