JavaScript

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What is a for loop?

For loops through a block of code a specified number of times

How do you enter comments at the end of a line?

In the following example the comment is placed at the end of a code line: Example <script type="text/javascript"> document.write("Hello"); // Write "Hello" document.write(" Dolly!"); // Write " Dolly!" </script>

How else can you prevent execution?

In the following example the comment is used to prevent the execution of a code block (can be suitable for debugging): Example <script type="text/javascript"> /* document.write("<h1>This is a heading</h1>"); document.write("<p>This is a paragraph.</p>"); document.write("<p>This is another paragraph.</p>"); */ </script>

How to use comments to prevent execution?

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>"); document.write("<p>This is a paragraph.</p>"); document.write("<p>This is another paragraph.</p>"); </script>

What is JavaScript Code?

JavaScript code (or just JavaScript) is a sequence of JavaScript statements. Each statement is executed by the browser in the sequence they are written. This example will write a heading and two paragraphs to a web page: Example <script type="text/javascript"> document.write("<h1>This is a heading</h1>"); document.write("<p>This is a paragraph.</p>"); document.write("<p>This is another paragraph.</p>"); </script>

Thinks to remember about JavaScript

JavaScript is case sensitive

Things to Remember about JavaScript

JavaScript is case sensitive.

What are JavaScript Blocks?

JavaScript statements can be grouped together in blocks. Blocks start with a left curly bracket {, and ends with a right curly bracket }. The purpose of a block is to make the sequence of statements execute together. This example will write a heading and two paragraphs to a web page: Example <script type="text/javascript"> { document.write("<h1>This is a heading</h1>"); document.write("<p>This is a paragraph.</p>"); document.write("<p>This is another paragraph.</p>"); } </script>

What is a loop?

Loops execute a block of code at a specified number of times, or while a specified condition is true.

How do you write a multi-line JavaScript comment?

Multi line comments start with /* and end with */. The following example uses a multi line comment to explain the code: Example <script type="text/javascript"> /* The code below will write one heading and two paragraphs */ document.write("<h1>This is a heading</h1>"); document.write("<p>This is a paragraph.</p>"); document.write("<p>This is another paragraph.</p>"); </script>

What is a JavaScript variable?

Variables allow us to give a piece of data a name, then reference that data by its name further along in our program. This way, we can reuse a piece of data without having to remember what its actual value was; all we have to do is remember a variable name. In JavaScript, we create a variable by using the keyword var and specifying the name we want to use:

What is a while loop?

While - loops through a block of code while a specified condition is true

What is a comment?

A comment is a note in your code that browsers will ignore completely. It is usually inserted to give you instruction on the code or to stop a statement from executing.

How to Insert JavaScript onto a Page

<html> <body><script type="text/javascript" >document.write('this will appear on the page') </script <html> <body>

How to Embed JavaScript onto a Page

<script type="text/javascript" src="file.js></script

How do you write a single-line JavaScript Comment?

<script type="text/javascript"> // Write a heading document.write("<h1>This is a heading</h1>"); // Write two paragraphs: document.write("<p>This is a paragraph.</p>"); document.write("<p>This is another paragraph.</p>"); </script>


Ensembles d'études connexes

Clinical Nutrition: Nutritionism

View Set

Lesson 4: Your business Snapshot

View Set

Intro to health science and medicine test 1

View Set

Disclosure of Health Information

View Set

American National Government We The People Final Review

View Set