A scripting language is a lightweight programming language
Contents contributed and discussions participated by Sunny Jackson
JavaScript Introduction - 0 views
-
-
Java and JavaScript are two completely different languages in both concept and design!
JavaScript Comments - 0 views
-
Comments can be added to explain the JavaScript, or to make the code more readable. Single line comments start with //.
-
Multi line comments start with /* and end with */.
-
In the following example the comment is used to prevent the execution of a single code line (can be suitable for debugging): Example <script type="text/javascript"> //document.write("<h1>This is a heading</h1>");
- ...2 more annotations...
JavaScript Statements - 0 views
-
JavaScript is Case Sensitive
-
A JavaScript statement is a command to a browser. The purpose of the command is to tell the browser what to do.
-
It is normal to add a semicolon at the end of each executable statement.
- ...6 more annotations...
JavaScript Where To - 0 views
-
JavaScripts in a page will be executed immediately while the page loads into the browser.
-
Scripts to be executed when they are called, or when an event is triggered, are placed in functions.
-
put all your functions in the head section, this way they are all in one place and do not interfere with page content.
- ...8 more annotations...
JavaScript How To - 0 views
-
The HTML <script> tag is used to insert a JavaScript into an HTML page.
-
<script type="text/javascript"> document.write("Hello World!"); </script>
-
how to add HTML tags to the JavaScript: Example <html> <body> <script type="text/javascript"> document.write("<h1>Hello World!</h1>"); </script> </body> </html>
- ...4 more annotations...
JavaScript Popup Boxes - 0 views
-
JavaScript has three kind of popup boxes: Alert box, Confirm box, and Prompt box.
-
Alert Box An alert box is often used if you want to make sure information comes through to the user. When an alert box pops up, the user will have to click "OK" to proceed.
-
Syntax alert("sometext");
- ...5 more annotations...
JavaScript Switch Statement - 0 views
-
The JavaScript Switch Statement Use the switch statement to select one of many blocks of code to be executed. Syntax switch(n) { case 1: execute code block 1 break; case 2: execute code block 2 break; default: code to be executed if n is different from case 1 and 2 }
-
Use break to prevent the code from running into the next case automatically.
JavaScript If...Else Statements - 0 views
-
Conditional statements are used to perform different actions based on different conditions.
-
if statement - use this statement to execute some code only if a specified condition is true
-
if...else statement - use this statement to execute some code if the condition is true and another code if the condition is false
- ...8 more annotations...
JavaScript Comparison and Logical Operators - 0 views
-
Comparison operators can be used in conditional statements to compare values and take action depending on the result: if (age<18) document.write("Too young");
-
JavaScript also contains a conditional operator that assigns a value to a variable based on some condition. Syntax variablename=(condition)?value1:value2
JavaScript Operators - 0 views
-
= is used to assign values.
-
+ is used to add values.
-
The + operator can also be used to add string variables or text values together.
- ...3 more annotations...
JavaScript Variables - 0 views
-
Variables are "containers" for storing information.
-
variables can be used to hold values (x=5) or expressions (z=x+y).
-
A variable can have a short name, like x, or a more descriptive name, like carname.
- ...8 more annotations...
JavaScript Break and Continue Statements - 0 views
-
The break Statement The break statement will break the loop and continue executing the code that follows after the loop (if any).
-
<script type="text/javascript"> var i=0; for (i=0;i<=10;i++) { if (i==3) { break; } document.write("The number is " + i); document.write("<br />"); } </script>
-
The continue Statement The continue statement will break the current loop and continue with the next value.
- ...1 more annotation...
JavaScript while Loop - 0 views
-
The while Loop The while loop loops through a block of code while a specified condition is true. Syntax while (variable<=endvalue) { code to be executed }
-
The do...while Loop The do...while loop is a variant of the while loop. This loop will execute the block of code ONCE, and then it will repeat the loop as long as the specified condition is true. Syntax do { code to be executed } while (variable<=endvalue);
JavaScript for Loop - 0 views
-
Loops execute a block of code a specified number of times, or while a specified condition is true.
-
In JavaScript, there are two different kind of loops: for - loops through a block of code a specified number of times while - loops through a block of code while a specified condition is true
-
The for Loop The for loop is used when you know in advance how many times the script should run. Syntax for (variable=startvalue;variable<=endvalue;variable=variable+increment) { code to be executed }
JavaScript Functions - 0 views
-
A function will be executed by an event or by a call to the function.
-
To keep the browser from executing a script when the page loads, you can put your script into a function.
-
A function contains code that will be executed by an event or by a call to the function.
- ...13 more annotations...
JavaScript Guidelines - 0 views
-
JavaScript is case sensitive - therefore watch your capitalization closely when you create or call variables, objects and functions.
JavaScript Special Characters - 0 views
-
In JavaScript you can add special characters to a text string by using the backslash sign.
-
Insert Special Characters The backslash (\) is used to insert apostrophes, new lines, quotes, and other special characters into a text string.
-
In JavaScript, a string is started and stopped with either single or double quotes.
- ...4 more annotations...
JavaScript Throw Statement - 0 views
-
The Throw Statement The throw statement allows you to create an exception. If you use this statement together with the try...catch statement, you can control program flow and generate accurate error messages. Syntax throw exception
-
throw is written in lowercase letters. Using uppercase letters will generate a JavaScript error!
JavaScript Try...Catch Statement - 0 views
-
The try...catch statement allows you to test a block of code for errors.
-
The try...catch Statement The try...catch statement allows you to test a block of code for errors. The try block contains the code to be run, and the catch block contains the code to be executed if an error occurs. Syntax try { //Run some code here } catch(err) { //Handle errors here } Note that try...catch is written in lowercase letters. Using uppercase letters will generate a JavaScript error!
-
The throw Statement The throw statement can be used together with the try...catch statement, to create an exception for the error
« First
‹ Previous
321 - 340 of 729
Next ›
Last »
Showing 20▼ items per page