javascript启示录

所需积分/C币:10 2014-01-13 15:45:06 6.89MB PDF

javascript启示录 javascript_enlightenment
JavaScript enlightenment Cody lindley ○ REILLY Beijing Cambridge. Farnham. Koln. Sebastopol Tokyo JavaScript enlightenment by Cody lindley Copyright O 2013 Cody Lindley. All rights reserved Printed in the United States of America Published by o reilly media, Inc, 1005 Gravenstein Highway North, Sebastopol, CA 95472 OReilly books may be purchased for educational, business, or sales promotional use. Online editions are alsoavailableformosttitles(http://my.safaribooksonline.com).foRmoreinformationcontactourcorporate institutionalsalesdepartment800-998-9938orcorporate@oreilly.com Editors: Simon St Laurent and Meghan blanchette Proofreader BIM Proofreading Services Production Editor: Kristen Borg Indexer: Ellen Troutman Zaig Cover Designer: Randy Comer Interior Designer: David Futato January 2013 First edition Revision history for the First Edition: 2012-12-18 First release Seehttporeillycom/catalog/errata.csp?isbn=9781449342883forreleasedetails Nutshell Handbook, the Nutshell Handbook logo, and the O Reilly logo are registered trademarks ofO Reilly Media, Inc. JavaScript Enlightenment, the image of a Eurasian eagle owl, and related trade dress are trade- marks of O Reilly Media, Inc Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O Reilly Media, Inc, was aware of a trade mark claim, the designations have been printed in caps or initial caps While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained h erein ISBN:978-1-449-34288-3 [LSI Table of contents Preface 1. JavaScript objects. Creating Objects JavaScript Constructors Construct and Return Object Instances The JavaScript Native/Built-In Object Constructors 11689 User-Defined/Non-Native Object Constructor Functions Instantiating Constructors Using the new Operator 10 creating Shorthand/Literal Values from Constructors 12 Primitive(a k.a. Simple) values The Primitive Values null, undefined, string, 10, true, and false Are Not Objects 15 How Primitive Values Are Stored/Copied in JavaScript 16 Primitive Values Are equal by value 17 The String, Number, and boolean primitive values act Like objects when Used Like Objects 18 Complex(a k.a. Composite) Values How Complex values are Stored/ Copied in javaScrip 20 Complex objects are Equal by reference 21 Complex objects Have Dynamic Properties 22 The typeof Operator Used on Primitive and Complex values 22 Dynamic Properties allow for Mutable Objects 23 All Constructor Instances Have Constructor Properties that point to Their Constructor function 24 Verify that an object is an Instance of a Particular Constructor Function 26 An Instance Created From a Constructor Can Have Its Own Independent Properties(Instance Properties 27 The Semantics of JavaScript Objects" and Object( Objects 29 2. Working with objects and properties. ·鲁·。 31 Complex objects Can Contain Most of the JavaScript Values as Properties 31 Encapsulating Complex Objects in a Programmatically Beneficial Way 32 Getting/Setting/Updating an Object's Properties Using Dot Notation or Bracket notation Deleting Object Properties 36 How References to Object Properties Are Resolved 36 Using hasOwnProperty, Verify That an Object Property Is Not From the Prototype chain 39 Checking If an Object Contains a Given Property Using the in Operator 39 Enumerate(Loop Over)an Objects Properties using the for in Loop Host Objects versus native objects 41 Enhancing and extending objects with Underscore. js 43 3. object( 鲁自鲁·鲁 45 Conceptual Overview of Using Object( Objects 45 ObjectO Parameters Object( Properties and Methods Object( Object Instance Properties and methods Creating Object( Objects USing Object Literals All Objects Inherit From Object. prototype 49 4. Function(............ 51 Conceptual Overview of Using Function( Objects 51 Function Parameters 52 Function( Properties and Methods 53 Function Object Instance Properties and methods 53 Functions Always Return a value 53 Functions Are First-Class Citizens(Not Just Syntax but Values 54 Passing parameters to a Function 55 this and arguments values available to all functions The arguments. callee Property 5 The Function Instance length Property and arguments. length 57 Redefining Function Parameters 58 Return a Function Before It Is Done( Cancel Function Execution) 58 Defining a Function(Statement, Expression, or Constructor) Invoking a Function[Function, Method, Constructor, or callO and apply] Anonymous Functions 61 Self-Invoking Function Expression 61 Self-Invoking Anonymous Function Statements 62 Functions Can be Nested Passing functions to Functions and returning Functions from Functions Invoking Function Statements Before They Are Defined(Function Hoisting) 64 Table of contents A Function Can Call Itself(Recursion) 5. The head/ Global object. 67 Conceptual Overview of the Head Object 67 Global Functions Contained Within the Head Object 68 The Head Object versus Global Properties and global variables 68 Referring to the Head object The Head Object Is Implied and Typically Not Referenced Explicitly 70 6. The this Conceptual Overview of this and How It Refers to objects 73 How Is the value of this determined? The this Keyword Refers to the head object in Nested Functions Working Around the Nested Function Issue by Leveraging the Scope Chain 77 Controlling the value of this Using callo or apply Using the this Keyword Inside a User-Defined Constructor Function The this Keyword Inside a Prototype method Refers to a Constructor instance 80 7. Scope and closures.. .................,....................................83 Conceptual Overview of JavaScript Scope 83 JavaScript Does Not Have Block Scope 84 Use var Inside Functions to Declare Variables and Avoid Scope Gotchas 85 The Scope Chain(Lexical Scoping 85 The Scope Chain Lookup Returns the First Found value 87 Scope Is Determined During Function Definition, not Invocation 87 Closures Are Caused by the scope chain 88 8. Function Prototype Property............ 91 Conceptual overview of the prototype chain 91 Why Care About the prototype Property 92 Prototype Is Standard on All function( Instances 93 The Default prototype Property Is an Object( object 3 Instances Created From a Constructor Function are Linked to the Constructor's prototype Property 94 Last stop in the prototype chain is object. prototype 95 The prototype Chain Returns the First Property Match It Finds in the Chain 96 Replacing the prototype property with a new object removes the default Constructor property 96 Instances That Inherit Properties from the prototype will always Get the Latest values 97 Replacing the prototype Property with a New Object Does Not Update Former instances 98 Table of Contents User-Defined Constructors Can Leverage the same prototype Inheritance as Native Constructors Creating Inheritance Chains(the Original Intention 100 9. Array0 Conceptual Overview of Using Array( Objects 103 Array Parameters 104 Array( Properties and Methods 104 Array object Instance Properties and methods 105 Creating arrays 105 Adding and updating values in arrays 106 Length versus index 107 Defining Arrays with a Predefined Lengt 107 Setting array length can add or remove values 108 Arrays Containing Other Arrays(Multidimensional Arrays) 108 Looping Over an Array, Backwards and Forwards 109 10. String( 111 Conceptual Overview of Using the String( Object 111 String Parameters String( properties and methods 112 String Object Instance Properties and Methods 112 11. Number( 15 Conceptual Overview of Using the Number( Object 115 Integers and Floating-Point Numbers 116 Number Parameters 116 Number( Properties 117 Number Object Instance Properties and Methods 117 12. Boolean(.….119 Conceptual Overview of Using the Boolean( Object Boolean parameters 120 Boolean( Properties and Methods 120 Boolean object instance Properties and methods 121 Non-Primitive False Boolean objects Convert to true 121 Certain Things Are false, Everything Else Is true 122 13. Working with Primitive String, Number, and Boolean Values. 123 Primitive/Literal values Are Converted to Objects When Properties are Accessed 123 ⅵi| Table of contents You Should Typically Use Primitive String, Number, and Boolean values 125 14.Nul., Conceptual Overview of Using the null value 127 typeof Returns null Values as object 127 15. Undefined ,129 Conceptual Overview of the undefined value 129 JavaScript ECMAScript 3 Edition(and Later) Declares the undefined variable in the global Scope 130 16. Math function ,131 Conceptual Overview of the Built-In Math Object 131 Math Properties and methods 131 Math Is not a constructor function 32 Math Has Constants You Cannot Augment/Mutate 133 A. Review ,135 B.〔 onclusion. 139 Index ,,,,,,141 Table of Contents

...展开详情

评论 下载该资源后可以进行评论 55

YIty_Zhang 挺好的,看了很有帮助
2016-09-25
回复
Tinker-star 很清晰
2016-08-14
回复
yongxing510 有空看看地方
2016-08-14
回复
linfang92926 非常好,好好看
2015-09-01
回复
yk447371921 最后我还是自己买了一本 感觉实体书看着 还是比较爽一点
2015-08-20
回复
img
tomnmy

关注 私信 TA的资源

上传资源赚积分,得勋章
相关内容推荐