1. Trang chủ
  2. » Mẫu Slide

slide môn học HDJ bài 7 the foundation of javascript syntax

30 630 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 30
Dung lượng 210,5 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

 JavaScript is a scripting language developed by Sun Microsystems and Netscape.. JavaScript effects and rules ► JavaScript can enhance the dynamics and interactivity of the site by usin

Trang 1

The Foundation of JavaScript Syntax

Session 7

Trang 2

 Describe JavaScript

 Understand foundation of JavaScript syntax

Trang 3

JavaScript JavaScript makes makes it it easier easier to to create create

dynamic and interactive Web pages.

JavaScript is a scripting language developed by Sun Microsystems and Netscape.

JavaScript developed from Netscape's Livescript.

Where is JavaScript running ?

Trang 4

JavaScript effects and rules

JavaScript can enhance the dynamics and interactivity of the site by using its effects.

Provide User Interaction

Dynamically Change Content

Validate data

Provide Database Interaction

Similar to any other language, JavaScript also follows some basic grammar rules like:

Using Caps JavaScript is case sensitive

Using Pairs Open and closed symbols need to work in pairs

Using Spaces JavaScript ignores extra white space

Using Comments make notes to yourself about what the script

is doing

Trang 5

JavaScript Tools and Run- Time

Environment

►The JavaScript code-generating tools and IDE helps in creating useful JavaScript code A few of these include:

►Run Time Environment

Trang 6

Client-Side JavaScript

►If a client-side script is embedded in the page, the server forwards the full content of the HTML document – The JavaScript statements and the HTML content

►When the browser receives the document, it executes the HTML and JavaScript statements without any interaction with the server

Trang 7

Server-Side JavaScript

►We can embedded JavaScript statements in

an HTML document that are executed on the server

executable in bytecode format

executable, the run-time engine executes the server-side JavaScript statements and returns the HTML page to the browser

►Some of the uses of server-side scripts

Trang 8

Embedding JavaScript in Web Page

document in the following ways :

 Using SCRIPT tag:

<script language="JavaScript">

JavaScript statements;

// >

</script>

 Using an external File

<script language="JavaScript" src="filename.js"> </script>

 Using JavaScript Expressions within HTML Tag

Attribute Values

 Using JavaScript in event handlers

Trang 9

Program Using Msg box and write

method

Example:

<HTML>

<HEAD>

<SCRIPT LANGUAGE = "Javascript">

confirm ("Are you Sure?");

Trang 10

they are declared in the script

 Global Variable

 Local Variable

Trang 12

Data Type - Example

Trang 13

Literal - Types

hexadecimal and binary number system.

point or an “e” or “”E” followed by an integer.

enclosed in single or double quotation marks.

False.

Trang 14

(operands) and return a new value

they perform like:

Trang 15

Arithmetic Operator

(either literals or variables) as their operands and return a single numerical value

Trang 16

Comparison Operator

and returns a logical value based on whether the comparison is true or not

Trang 17

Logical Operators

multiple comparisons into a conditional

expression

Trang 18

Logical Operators - Example

alert ("The value of x is "

+ x + "The value of y is " + y);

alert("x AND y = " + (x && y));

Trang 19

String Operator

operands and creates a new string, which is same, as the two original strings run together

Example:

x = ‘yellow’;

y = ‘green’;

z = x + y + ‘white’;

which means z is “yellowgreenwhite”

w = y + 9, which means w is “green9”

Trang 20

Evaluation Operator

Conditional operator

condition) ? trueVal : falseVal

Assigns a specified value to a variable if a condition is

true, otherwise assigns an alternate value if condition

is false

eg.

status = (age >= 18) ? "adult" : "minor“

Typeof operator

The typeof operator returns a string indicating the

type of the operand.

eg

var x = 5;

Trang 21

Operator Precedence

When there are several operators to be evaluated in

an expression, the precedence of the operator determines the sequence in which the operators are evaluated

The following table lists the precedence of

operators, from lowest to highest:

Trang 22

variables in different contexts

and operators which evaluates to a single value

Arithmetic: evaluates to a number

Logical: evaluates to a boolean value

String: evaluates to a string

together via operators

Trang 23

Regular Expression

be used to match the character combinations of a string

character patters in a string input by the user

 Simple patterns

 Combination of simple and special characters

ways:

 Using an object initializer

Trang 24

Using Regular Expression

Expression includes:

 Exec, Test, Match, Search, Replace, Split

of the object is:

Trang 25

Regular Expression - Example

str = re.test ("Time and Tide

wait for none");

Trang 26

the same name

value

arrayObjectName = new Array([element0, element1, ,

elementN])

we create it Eg emp[0] = "Ryan Dias"

Trang 27

manipulate the array

Trang 28

Conditional Statements

► A conditional statement is used to test a

condition The result determines the statement or block of statements to be executed.

► The various conditional statements include:

 If… Else

 Switch

Trang 30

JavaScript has several pre-defined functions that

we can use within the script.

Some of pre-defined JavaScript functions

Ngày đăng: 30/11/2016, 22:10

TỪ KHÓA LIÊN QUAN

w