Home » Posts tagged "Learn Java Script Online"

Learn Java Script, Streamlining Your Scripts with Functions and Calling Functions , Lesson No. 28

A function is a collection of statements that performs a given task. Most functions are defined in the head section of HTML pages. Putting your functions in the head section is a good idea for two reasons: The first is that you’ll always know where your functions are because they’re in a common location. The second reason is that the head section always executes first, ensuring that functions are available when...
Continue reading »

Learn Java Script, Manipulating Objects and With Statement, Lesson No. 27

As I have already stated, JavaScript and JScript enable you to create scripts that work with objects. You can think of objects as being similar to variables except that objects can contain multiple values known as its properties. Objects also can contain built-in functions, which are collections of predefined script statements that are designed to work with the object and its data. Examples of browser objects include browser windows and form...
Continue reading »

Learn Java Script, The break Statement and continue Statement, Lesson No. 26

    The break statement lets you terminate a label, switch, or loop. The script then continues processing with the statement that follows the label, switch, or loop statement that was broken out of. The following example shows how to use the break statement to terminate the execution of a while loop. In this case, the break statement terminates the loop when the value of counter becomes equal to 5. Because...
Continue reading »

Learn Java Script, The label Statement, Lesson No. 25

  The label statement lets you specify a reference point in your script. Typically, the label statement is associated with loops. A label statement can be referenced by either the break or continue statement. The syntax of the label statement is shown here: label: statements; In the following example, I have created a label called CounterLoop. When the script executes the first time, the label statement is ignored. Within the while...
Continue reading »

Learn Java Script, The do…while Statement, Lesson No. 24

The do…while statement executes a loop until a condition becomes false. The syntax of the do…while statement is outlined below: do { statements; } while (condition) The difference between the do…while loop and the while loop is that the do…while loop always executes at least once. This is because the condition is checked at the end of the first execution of the loop instead of at the beginning. However, you can...
Continue reading »

Learn Java Script, The while Statement, Lesson No. 23

    The while statement executes a loop as long as a condition is true. The syntax of the while statement is shown here: while (condition) { statements; } For example, you might write a while loop that looks like this: while (counter > 0) { counter++; document.write(“counter = “, counter , “<BR>”); } In the next example, I set up a loop that runs as long as the value assigned...
Continue reading »

Learn Java Script, Optimizing Code with Looping Logic, Lesson No. 22

    A loop is a series of statements that executes repeatedly, allowing you to perform iterative operations within your script. JavaScript and JScript statements that support looping logic include the for, while, do…while, label, break, and continue statements. The nice thing about loops is that they enable you to write just a few line of code and then to execute them repeatedly, making your scripts easier to write and maintain....
Continue reading »

Learn Java Script, Adding Comments for Clarity, Lesson No. 21

    Comment statements have no effect on the logical performance of the script. However, they can be used to make scripts easier to understand by providing you with a means of internally documenting your scripts. You can place a comment in your scripts in either of two ways. To place a single comment line within the body of your script, type // followed by your comment, as shown here: //This...
Continue reading »