WHAT A LAMP Rotating Header Image

Posts under ‘JavaScript’

Working with variables

A variable is a named placeholder for a value. You can use the var keyword to construct an expression that first declares a variable and then (optionally) initializes its value. How to declare a variable: var myName; How to initialize a value: var myName = “David Yin” Technically, you can declare a variable in JavaScript [...]

Operators of JavaScript

Every computer language has operators. JavaScript has following items: There are two categories of operators. Binary: Two items (or operands) must be sandwiched on either side of the operator. Unary: onely one operand is required. Arithmetic Operators Operator Description Example Result + Addition x=2y=2x+y 4 – Subtraction x=5y=2x-y 3 * Multiplication x=5y=4x*y 20 / Division [...]

Add comments to scripts

The JavaScript interpreter ignores comments. Comments do have value, though; they’re very useful for explaining things to human readers of your script. Of course, including yourself. 1) Single-line comment //Single-line comments don’t require an ending slash. 2) Multiple-line comment /* This comment can span multiple lines. Always remember to close it. Though; if you forge. [...]

Where to put Javascript

JavaScripts in the body section will be executed WHILE the page loads. Scripts will be executed when they are called, or when an event is triggered, go in the head section. When you place a script in the head section, you will ensure that the script is loaded before anyone uses it. <html> <head> <script [...]

What is Javascript

What is JavaScript? * JavaScript was designed to add interactivity to HTML pages * JavaScript is a scripting language (a scripting language is a lightweight programming language) * A JavaScript consists of lines of executable computer code * A JavaScript is usually embedded directly into HTML pages * JavaScript is an interpreted language (means that [...]