Slide 1

Slide 1 text

JAVAsCrIpT JAVAsCrIpT Mohamed Loey

Slide 2

Slide 2 text

AgENdA Part I: Introduction Part II: JavaScript Syntax

Slide 3

Slide 3 text

AgENdA Part I: Introduction  What is JavaScript?  JavaScript In HTML  JavaScript Can

Slide 4

Slide 4 text

WHAT Is JAVAsCrIpT? • JavaScript is the first Web scripting language, developed by Netscape in 1995 • JavaScript is a scripting language. It is a lightweight, • JavaScript is a scripting language. It is a lightweight, but powerful, programming language. • JavaScript similarities to Java/C++ • JavaScript is Client-side web programming • JavaScript is the most popular programming language in the world.

Slide 5

Slide 5 text

JAVAsCrIpT IN HTml • In HTML, JavaScripts must be inserted between and tags. • • JavaScripts can be put in the and in the section of an HTML page. • Two Ways to Insert JavaScript: 1. Internal script 2. External script sheet

Slide 6

Slide 6 text

INTErNAl sCrIpT • Scripts can be placed in the or in the section of HTML, and/or in both. section of HTML, and/or in both. • Example:

Slide 7

Slide 7 text

ExTErNAl sCrIpT sHEET • Scripts can also be placed in external files. • • External scripts are practical when the same code is used in many different web pages. • JavaScript files have the file extension .js. • To use an external script, put the name of the script file in the source (src) attribute of the tag

Slide 8

Slide 8 text

ExTErNAl sCrIpT sHEET • Example:

Slide 9

Slide 9 text

JAVAsCrIpT CAN • Change HTML Elements • • Change HTML Attributes • Change HTML Styles (CSS) • Validate Data

Slide 10

Slide 10 text

AgENdA Part II: JavaScript Syntax  JavaScript is Case Sensitive  JavaScript Comments  JavaScript Variables  JavaScript Conditions  JavaScript Loops  JavaScript Arrays

Slide 11

Slide 11 text

JAVAsCrIpT Is CAsE sENsITIVE • In JavaScript all identifiers are case sensitive. • The variables lastName and lastname, are two different variables. • The functions myFunction and myfunction, are two different functions. • JavaScript does not interpret Var; as var.

Slide 12

Slide 12 text

JAVAsCrIpT CommENTs • Single Line Comments • Single line comments start with //. • Multi-line Comments • Multi-line comments start with /* and end with */.

Slide 13

Slide 13 text

JAVAsCrIpT VArIAblEs • JavaScript uses the var keyword to define variables • Example:

Slide 14

Slide 14 text

JAVAsCrIpT VArIAblEs • JavaScript uses the var keyword to define variables • Example:

Slide 15

Slide 15 text

JAVAsCrIpT CoNdITIoNs • In JavaScript we have the following conditional statements: statements: 1. Use if to specify a block of code to be executed, if a specified condition is true 2. Use else to specify a block of code to be executed, if the same condition is false 3. Use else if to specify a new condition to test, if the first condition is false 4. Use switch to specify many alternative blocks of code to be executed

Slide 16

Slide 16 text

JAVAsCrIpT CoNdITIoNs • Example:

Slide 17

Slide 17 text

JAVAsCrIpT loops • JavaScript supports different kinds of loops: 1. for - loops through a block of code a number of times 2. for/in - loops through the properties of an object 3. while - loops through a block of code while a specified condition is true 4. do/while - also loops through a block of code while a specified condition is true

Slide 18

Slide 18 text

JAVAsCrIpT loops • Example:

Slide 19

Slide 19 text

JAVAsCrIpT ArrAys • JavaScript arrays are used to store multiple values in a single variable. • Example:

Slide 20

Slide 20 text

JAVAsCrIpT FUNCTIoNs • A JavaScript function is a block of code designed to perform a particular task. • A JavaScript function is executed when "something" invokes it (calls it). • Example:

Slide 21

Slide 21 text

THANK U THANK U