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

slide môn học HDJ bài 8 the core language objects in javascript

24 283 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 24
Dung lượng 219 KB

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

Nội dung

 Work on Core Language Objects  Use object Attributes and Methods...  The properties variables that define the object and the methods functions that work on the data are included in t

Trang 1

The Core language Objects in JavaScript

Session 8

Trang 2

A Recap

 Scripting Language – Scenarios Language

 JavaScript’s Elements

 Core JavaScript Object

 Client-Side JavaScript Object

 Server-Side JavaScript Object

Trang 4

 Work on Core Language Objects

 Use object Attributes and Methods

Trang 5

 The properties (variables) that define the object and the methods (functions) that work

on the data are included in the object

 For example, a car is an object The properties of the car are its make, model, and color They have some common methods like,

go (), brake(), reverse()

Trang 6

Properties and Methods

 To access the properties of the object, we must specify the object name and the property:

objectName.propertyName

 To access the methods of an object, we must

specify the object name and the required method:

objectName.method ()

Trang 8

Using objects

 When creating a Web page we can insert:

 Browser objects

 Built in script language objects (vary depending

on the scripting language used)

 HTML elements

 We can also create our own objects for use

in the programs

Trang 9

Object Hierarchy

Browser Objects

Script Objects

HTML Elements

Trang 10

The this statement

 The this statement is more of an internal property

 Its value indicates the current object It can have standard properties such as name, length and value applied accordingly

Trang 11

The for in statement

 The for in statement is used to cycle through each property of an object or each element of an array

 The syntax is:

for (variable in object)

{ statements; }

Trang 12

The with statement

 The with statement is used to execute a set

of statements that have a specified object as the reference

 The property is assigned to the object specified in the with statement

 The syntax is:

with (object) { statements; }

Trang 13

New Operator

 The new operator is used to create a new

instance of an object type

 The object type may be user-define or built-in

 objectName = new objectType (param1

[,param2] [,paramN])

where,

objectName is the name of the new object instance.

ObjectType is a function that defined the type of the object For

example, Array.

Trang 14

Eval function

 The eval function is used to evaluate a string

of code without reference to any specific

object

 The string can be a JavaScript expression,

statement, or a group of statements

 The expression can include variables and

properties of an object

var x = 5;

var z = 10;

document.write(eval(“x + z + 5”));

Trang 16

Creating String object

 There are 3 different methods of creating

Trang 18

Math Object

 The Math object has properties and

methods that represent advanced

}

Trang 21

Date object

 The Date object stores dates as the number

of milliseconds since January 1, 1970,

00:00:00

DateObject = new Date(parameters)

Trang 24

One Shot Timer

setTimeout(“javaScript code”, delay)

Timer that Fires at Regular Intervals

setInterval(“javaScript code”, interval)

clearInterval(handler)

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

TỪ KHÓA LIÊN QUAN