`
liuqiyu
  • 浏览: 27233 次
  • 性别: Icon_minigender_1
  • 来自: 珠海
社区版块
存档分类
最新评论

JavaScript The Definitive Guide Note Part 1

阅读更多

Part 1 Core JavaScript 

Chapter 2. Lexical Structure

2.1 Character Set 

JavaScript programs are written using the Unicode character set.

2.2 Case Sensitivity

2.3. Whitespace and Line Breaks

     JavaScript ignores spaces, tabs, and newlines that appear between tokens in programs

2.4. Optional Semicolons

2.5. Comments

//comments  and /*comments*/

2.6. Literals

2.7. Identifiers

The first character must be a letter, an underscore (_), or a dollar sign ($).

2.8  Reserved Words

Table 2-1. Reserved JavaScript keywords

break

do

if

switch

typeof

case

else

in

this

var

catch

false

instanceof

tHRow

void

continue

finally

new

true

while

default

for

null

try

with

delete

function

return

 

Table 2-2. Words reserved for ECMA extensions

 

abstract

double

goto

native

static

boolean

enum

implements

package

super

byte

export

import

private

synchronized

char

extends

int

protected

throws

class

final

interface

public

TRansient

const

float

long

short

volatile

debugger

 

 

 

as, is, namespace, and use

Chapter 3. Datatypes and Values

 3.1. Numbers

3.1.1. Integer Literals

represent all integers between -9007199254740992 (-253) and 9007199254740992 (253)

3.1.2. Hexadecimal and Octal Literals

0x 0X 0

3.1.3. Floating-Point Literals

[digits][.digits][(E|e)[(+|-)]digits]

Special numeric constants

Constant

Meaning

Infinity

Special value to represent infinity

NaN

Special not-a-number value

Number.MAX_VALUE

Largest representable number

Number.MIN_VALUE

Smallest (closest to zero) representable number

Number.NaN

Special not-a-number value

Number.POSITIVE_INFINITY

Special value to represent infinity

Number.NEGATIVE_INFINITY

Special value to represent negative infinity

3.2. Strings

3.2.2. Escape Sequences in String Literals

Table 3-2. JavaScript escape sequences

Sequence

Character represented

\0

The NUL character (\u0000).

\b

Backspace (\u0008).

\t

Horizontal tab (\u0009).

\n

Newline (\u000A).

\v

Vertical tab (\u000B).

\f

Form feed (\u000C).

\r

Carriage return (\u000D).

\"

Double quote (\u0022).

\'

Apostrophe or single quote (\u0027).

\\

Backslash (\u005C).

\xXX

The Latin-1 character specified by the two hexadecimal digits XX.

\uXXXX

The Unicode character specified by the four hexadecimal digits XXXX.

\XXX

The Latin-1 character specified by the octal digits XXX, between 1 and 377. Not supported by ECMAScript v3; do not use this escape sequence.

3.2.4. Converting Numbers to Strings

String(number) 

Number.toString(number)

toFixed

toExponential

toPrecision

var n = 123456.789;
n.toFixed(0);         // "123457"
n.toFixed(2);         // "123456.79"
n.toExponential(1);   // "1.2e+5"
n.toExponential(3);   // "1.235e+5"
n.toPrecision(4);     // "1.235e+5"
n.toPrecision(7);     // "123456.8"

3.2.5. Converting Strings to Numbers

When a string is used in a numeric context, it is automatically converted to a number.

by simply subtracting zero from it

Number(string_value);
parseInt("ff", 16); //255

parseFloat('string')

3.3. Boolean Values

true  --> 1

false --> 0

true --> 'true'

false --> 'false'

number --> true

0,NaN --> false

'' --> false

'string' --> true

null, undefined --> false

Boolean(arg);

3.4. Functions

function square(x) { return x*x; }

var square = function(x) { return x*x; }

var square = new Function("x", "return x*x;");

3.5. Objects

3.5.1. Creating Objects

var o = new Object( );
var now = new Date( );
3.5.3. Object Conversions

3.6. Arrays

3.6.1. Creating Arrays

var a = new Array( );
a[0] = 1.2;
a[1] = "JavaScript";
a[2] = true;
a[3] = { x:1, y:3 };
var a = new Array(1.2, "JavaScript", true, { x:1, y:3 });
var a = new Array(10);
var a = [1.2, "JavaScript", true, { x:1, y:3 }];

3.5.2. Object Literals

3.7. null

null is a special value that indicates no value

3.8. undefined

undefined is returned when you use either a variable that has been declared but never had a value assigned to it or an object property that does not exist. Note that this special undefined value is not the same as null.

3.9. The Date Object

3.12. Type Conversion Summary

Table 3-3. Automatic datatype conversions

Value

Context in which value is used

 

String

Number

Boolean

Object

Undefined value

"undefined"

NaN

false

Error

null

"null"

0

false

Error

Nonempty string

As is

Numeric value of string or NaN

TRue

String object

Empty string

As is

0

false

String object

0

"0"

As is

false

Number object

NaN

"NaN"

As is

false

Number object

Infinity

"Infinity"

As is

true

Number object

Negative infinity

"-Infinity"

As is

TRue

Number object

Any other number

String value of number

As is

true

Number object

true

"true"

1

As is

Boolean object

false

"false"

0

As is

Boolean object

Object

toString( )

valueOf( ), toString( ), or NaN

true

As is

 

covers advanced material

3.13. Primitive Datatype Wrapper Objects

3.14. Object-to-Primitive Conversion

3.15. By Value Versus by Reference

 

 

评论

相关推荐

    JavaScript The Definitive Guide 5th 权威指南 第五版 英文 教材

    JavaScript The Definitive Guide 5th 权威指南 第五版 英文 教材 非常经典的javascript学习资料

    JavaScript - The Definitive Guide 4th edtion

    《JavaScript - The Definitive Guide 4th Edition》是一本权威的JavaScript编程指南,由David Flanagan撰写。这本书深入浅出地介绍了JavaScript的核心概念、语法和应用,是开发者必备的参考书籍之一。作为第四版,...

    JavaScript The Definitive Guide

    JavaScript The Definitive Guide JavaScript The Definitive Guide

    JavaScript The Definitive Guide 中文第四版

    **JavaScript The Definitive Guide**,也被称为"犀牛书",是JavaScript编程领域的一本经典著作,由David Flanagan撰写。中文第四版是针对这个备受赞誉的指南的最新中文翻译,旨在帮助中国读者深入理解和掌握...

    JavaScript: The Definitive Guide, 5th Edition

    《JavaScript: The Definitive Guide, 5th Edition》是JavaScript学习领域中一本经典的参考书,由David Flanagan撰写,全面且深入地介绍了JavaScript语言。这本书面向已经有一定编程基础的读者,旨在帮助他们掌握...

    JavaScript The Definitive Guide 6th Edition

    《JavaScript The Definitive Guide 6th Edition》是JavaScript编程领域的经典之作,由David Flanagan撰写,面向希望深入理解和精通JavaScript的开发者。这本书全面、详细地介绍了JavaScript的核心概念和技术,帮助...

    javascript the definitive guide 4th.rar

    javascript the definitive guide 4th.rarjavascript the definitive guide 4th.rarjavascript the definitive guide 4th.rarjavascript the definitive guide 4th.rarjavascript the definitive guide 4th....

    Javascript 权威指南 第6版 JavaScript The Definitive Guide 6th Edition

    《JavaScript权威指南第六版》是JavaScript开发者不可或缺的参考书籍,由David Flanagan撰写,Oreilly出版社出版。这本书深入浅出地介绍了JavaScript的核心概念、语法和API,为读者提供了全面而权威的JavaScript知识...

    802.11详解 802.11 Wireless Networks- The Definitive Guide

    Wireless Networks: The Definitive Guide 这个比直接看802.11 协议要舒服一些。理解更方便。 802.11® Wireless Networks: The Definitive Guide By Matthew Gast Publisher : O'Reilly Pub Date : April 2002 ISBN...

    Spark The Definitive Guide-201712

    《Spark The Definitive Guide-201712》是大数据处理领域中一本非常重要的参考资料,由知名数据工程师及作者Bill Karwin 和 Databricks 的团队共同编写。这本书全面覆盖了Apache Spark的核心概念、技术和最佳实践,...

    JavaScript_The Definitive Guide 4th Edition(searchable)

    JavaScript_The Definitive Guide 4th Edition(searchable)

    Cassandra The Definitive Guide(2nd) azw3

    Cassandra The Definitive Guide(2nd) 英文azw3 第2版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

    The Definitive Guide to Django 2nd Edition

    《The Definitive Guide to Django 2nd Edition》是一本深度解析Django框架的权威指南,旨在帮助初学者和有经验的开发者全面掌握Django的使用。这本书分为两个主要部分,确保读者能够从基础到高级逐步提升自己的技能...

    JavaScript - The Definitive Guide 第六版

    《JavaScript权威指南》第六版是一本由David Flanagan撰写的关于JavaScript编程语言的详尽指南。该书深入探讨了JavaScript的核心特性,涵盖了从基础语法到高级编程技术的广泛内容。第六版作为该系列书籍的最新版本,...

    HTML XHTML The Definitive Guide.part1

    HTML XHTML The Definitive Guide.part1

Global site tag (gtag.js) - Google Analytics