« Home « Kết quả tìm kiếm

Tài liệu JavaScript cơ bản đến nâng cao: The Definitive Guide Ebook PDF


Tóm tắt Xem thử

- 10.3 The RegExp Object 261.
- 15.1 Overview of the DOM 361.
- 22.7 The Filesystem API 700.
- The core of Part I—the chapters covering objects, arrays, functions, and classes—is all new and brings the book in line with current programming styles and best practices.
- JavaScript is the programming language of the Web.
- Netscape submitted the language for standardization to ECMA—the European Computer Manufacturer’s As- sociation—and because of trademark issues, the standardized version of the language was stuck with the awkward name “ECMAScript.” For the same trademark reasons, Microsoft’s version of the language is formally known as “JScript.” In practice, just about everyone calls the language JavaScript.
- The curly brace marks the end of the object..
- 2: the first element (index 0) of the array..
- 7: the last element of the array..
- The elements of the arrays are arrays..
- and the value of the expression.
- Semicolon marks the end of the assignment..
- Second element of the "this".
- This is the end of the if clause..
- and insert it at the end of the body..
- For each of the 2 points var y = amountToY(ticks[i.
- “Hello World.” The kinds of values that can be represented and manipulated in a programming language are known as types, and one of the most fundamental charac- teristics of a programming language is the set of types it supports.
- When a program needs to retain a value for future use, it assigns the value to (or “stores” the value in) a variable.
- Each constructor defines a class of objects—the set of objects initialized by that constructor.
- When an object is no longer reachable—when a program no longer has any way to refer to it—the interpreter knows it can never be used again and automatically reclaims the memory it was occupying..
- To determine the length of a string—the number of 16-bit values it contains—use the length property of the string.
- This code tests to see whether the value of the variable a is equal to the number 4 .
- If a is not equal to 4 , the result of the comparison is false.
- parseInt() accepts an optional second argument specifying the radix (base) of the number to be parsed.
- Creates a deletable property of the global object..
- 3.10.3 The Scope Chain.
- Since the scope chain differs on each invocation of the outer function, the inner function will be subtly different each time it is defined—the code of the inner function will be identical on each invocation of the outer function, but the scope chain associated with that code will be different..
- Evaluates to the value of the variable i..
- Evaluates to the value of the variable sum..
- This function returns the square of the value passed to it..
- If the value of the function expression is not a callable object, a TypeError is thrown..
- Otherwise, the value of the invocation expression is undefined .
- The return value of the.
- operators test for the exact opposite of the.
- Finally, note that the <= (less than or equal) and >= (greater than or equal) operators do not rely on the equality or strict equality operators for determining whether two values are “equal.” Instead, the less-than-or-equal operator is simply defined as “not greater than,” and the greater-than-or-equal operator is defined as “not less than.” The one exception occurs when either operand is (or converts to) NaN , in which case all four comparison operators return false.
- All other values, including all objects, are truthy.) The second level at which &&.
- The value of an assignment expression is the value of the right-side operand.
- it will obtain the value of the local variable..
- it changes the value of the local variable.
- 4.13.1 The Conditional Operator.
- While you can achieve similar results using the if statement (§5.4.1), the.
- 4.13.2 The typeof Operator.
- In order to distinguish one class of object from another, you must use other techniques, such as the instanceof operator (see §4.9.4), the class attribute (see §6.8.2), or the constructor property (see §6.8.1 and §9.2.2)..
- 4.13.3 The delete Operator.
- Delete the last element of the array a.length.
- Delete one of the object properties.
- Define a property of the a global object without var delete x.
- 4.13.4 The void Operator.
- 4.13.5 The Comma Operator.
- Here’s the syntax:.
- Note that the curly braces are a required part of the function statement.
- With var , only the variable declaration is hoisted—the variable initialization code remains where you placed it.
- Once the loop has executed 10 times, the expression becomes false (i.e., the variable count is no longer less than 10), the while statement finishes, and the interpreter can move on to the next statement in the program.
- The following code uses a for loop to traverse a linked list data structure and return the last object in the list (i.e., the first object that does not have a next property):.
- Jump to the next iteration of the named loop.
- Here’s the syntax of the return statement:.
- The rest of the function goes here..
- In strict mode, the arguments object (§8.3.2) in a function holds a static copy of the values passed to the function.
- In addition to maintaining its own set of properties, a JavaScript object also inherits the properties of another object, known as its “prototype.” The methods of an object are typically inherited properties, and this “prototypal inheri- tance” is a key feature of JavaScript..
- The writable attribute specifies whether the value of the property can be set..
- the value of the expression (it may be a primitive value or an object value) becomes the value of the property.
- These are the topics of the next section..
- property of the book..
- property of the author..
- operator to access the properties of the portfolio object.
- Now suppose you assign to the property x of the object o .
- The return value of this method becomes the value of the property access expression.
- The return value of the setter method is ignored..
- Try to change the value of the property.
- (Review §6.1.3 and §6.2.2 for more on prototypes and property inheritance.) This is such an important attribute that we’ll usually simply say “the prototype of o ” rather than “the prototype attribute of o.
- 6.10.1 The toString() Method.
- it returns a string that somehow represents the value of the object on which it is invoked.
- 6.10.2 The toLocaleString() Method.
- 6.10.3 The toJSON() Method.
- 6.10.4 The valueOf() Method.
- A reference to the array should appear to the left of the brackets.
- JavaScript converts the numeric array index you specify to a string—the index 1 be- comes the string "1".
- This the 1001st element of the array a[1.000.
- 10 rows of the table for(var i = 0.
- If an array contains undefined elements, they are sorted to the end of the array..
- If you only care about the value of the array element, you can write a function with only one parameter—the additional arguments will be ignored:.
- Compute the sum of the array elements.
- On subsequent calls, it is the value returned by the pre- vious invocation of the function.
- The length of the array to be searched pos = 0.
- Filter the characters of the string function(x).
- In addition to the arguments, each invocation has another value—the invocation context—that is the value of the this keyword..
- The value of an invocation of the printprops() function is always undefined .
- In the body of the function, a reference to a parameter evaluates to the corresponding argument value..
- Method m of the object..
- In this case, the new object is the value of the constructor invocation expression.
- Append the names of the enumerable properties of object o to the.
- Also note the use of the comment.
- Displays the initial value of the argument arguments[0.
- Copy length elements of the array from to the array to..
- It is hard to remember the order of the arguments..
- Return the sum of the elements of array (or array-like object) a..
- It is better to store the information in a property of the Function object.
- Initialize the counter property of the function object..
- a simple version of the extend() function.
- the toString property of the test object