|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
JS Tutorial
Part I - JS language
Part II- JS objects
Part III - Client-Side JS |
JavaScript Chapter 2 - Fundamentals 2.1 Embedding a script in an HTML document You can embed JavaScript in the HTML document in one of two ways:
If JavaScript is embedded using a beginning and ending script tag, the browser starts by finding the first script tag and then reads everything that follows until the ending script tag. JavaScript translates each line of code into instructions to perform. 2.2 Events Events are actions created by user actions on an HTML element.
An event can trigger an execution of JavaScript codes to
perform a desire goal. For example, we can use the Examples of events:
Note: Events are normally used in combination with functions, and the function will not be executed before the event occurs! 2.3 Basic syntax 2.3.1 Indentifier: Identifiers are simply names that represent variables, methods, or objects. A syntactically-valid identifier must:
2.3.2 Keywords: Keywords are predefined identifiers that make up the core of a programming language. In JavaScript, they perform unique functions, such as declaring new variables and functions, making decision based on the present state of the computer, or starting a repetitive loop inside your application. The following is a list of keywords available in JavaScript:
JavaScript version 1.1 added the following keywords: typeof and void. JavaScript verion 1.2 adds the followign keywords: do, labeled, switch and while. 2.3.3 Reserved Words: Reserved Words are identifiers tht you may not use as names for JavaScript variables, functions, objects or methods. The following is a complete list of the reserved words for JavaScript:
2.3.4 Literals: Literals are data comprised of numbers or string used
to represent fixed values in JavaScript. The literals don't change
during the execution of scripts. There are five types of literals: Integer Literals can be expressed in either decimal (base 10), octal (base 8), or hexadecimal (base 16) format. A zero infront of an integer literal designates octal form. The integer itself can include a sequecne of degits from 0 through 7. To designate hexadecimal, 0x (or 0X) is used before the integer. Hexadecimal integers can include digits from 0 through 9 along with the letters a through f or A through F. Here are example:
Floating-Point Literals represent decimal numbers with fractional parts. They can be expressed in either standard or scientific notation. With scientific notation, use either e or E to designate the exponent. Both the decimal number and exponent can be either signed or unsigned (positive or nagative). Example: 3405.673 Boolean Literials: JavaScript implements boolean data types and supports the two literals, true and false. They represent the Boolean vlaues 1 and 0 respectively, and must appear in lowercase. String Literials: a string literial is zero or more characters enclosed in double quotes (") or single quotes ('). Special Characters: When writting scripts, you might sometimes need to tell the computer to use a special characters or keywords, such as tab or new line. All speciall characters are preceded by a backslash (\), as shown bellow:
|
References(1) Aland Shalloway & James R. Trott, Design Patterns Explained, Second Edition.(2) Allen Holub, Holub on Patterns, Learning Design Patterns by Looking at Code (3) Eric Evans, Domain-Driven Design, Tackling complexity in the heart of software. Advertisement |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||