-
Notifications
You must be signed in to change notification settings - Fork 0
JavaScript
JavaScript is a programming language. Even though the name contains Java, it has little to do with this programming language.
JavaScript is the programming language of a Chrome Application. It is JavaScript that is executed when we use the mouse or the keyboard to interact with our application.
Statements describe things to do. Each statement is ended with a semi-colon (;). Multiple statements can be combined into a set of curly brackets {} called a block statement. A block statement is not ended with a semi-colon.
statement1;
statement2;
{
statement3;
statement4;
}Please note that block statements do not provide a scope. In other languages such as Java, something inside curly brackets are considered private to that area, but this is not the case in JavaScript
Variables must be declared with the var keyword followed by the name of the variable. You can optionally also assign a value when you declare variables. Once declared, the var keyword must not be used.
var some;
var other = 5;
other = 6;Names of variables must not be one of the keywords or built-in global variables.
The if...else statement is used to execute some statements if a condition is true and something else if it is false.
var a = 5;
if(a < 6) {
statement1;
statement2;
} else {
statement3;
statement4;
}Since the variable a has the value 5 which is less than 6, statements statement1 and statement2 will be executed.
The following is considered false:
undefined, null, 0, NaN, ""
An object in JavaScript
A JavaScript file is loaded from an HTML5 page using the script element.
<html>
<head>
<script type="text/javascript" src="background.js">Your browser does not support JavaScript</script>
</head>
<body>
</body>
</html>The type attribute indicates the type of script. It is necessary to specify this because browsers support other script languages. Internet Explorer for example has its own types; JScript, and VBScript.
The src attribute gives the name of the file that contains the JavaScript source code.
Introduction
[Install CDE](Install CDE)
[A Ringing Bell](A Ringing Bell)
[Projectile Movement](Projectile Movement)
[Map with location](Map with location)
[Slide 15 Puzzle](Slide 15 Puzzle)
[A Running Man](A Running Man)
Sudoku
[Package Chrome Application](Package Chrome Application)
[Uploading Your Application](Uploading Your Application)