Book description
If you’re an advanced beginner or intermediate JavaScript developer, JavaScript Enlightenment will solidify your understanding of the language—especially if you use a JavaScript library. In this concise book, JavaScript expert Cody Lindley (jQuery Cookbook) provides an accurate view of the language by examining its objects and supporting nuances.
Libraries and frameworks help you build web applications quickly and efficiently, but when things go wrong or performance becomes an issue, knowing how and why they work is critical. If you’re ready to go under the hood and get your hands dirty with JavaScript internals, this is your book.
- Get a short and digestible summary of ECMA-262, Edition 3, backed by real code you can run instantly
- Examine the creation of JavaScript objects
- Learn complex values, primitive values, scope, and inheritance
- Understand the importance of the head object
- Work with string, number, and Boolean objects and values
- Discover how to use the null value and the built-in math object
- Get into the details—beyond Mozilla’s reference guide for JavaScript 1.5
Publisher resources
Table of contents
- Preface
-
1. JavaScript Objects
- Creating Objects
- JavaScript Constructors Construct and Return Object Instances
- The JavaScript Native/Built-In Object Constructors
- User-Defined/Non-Native Object Constructor Functions
- Instantiating Constructors Using the new Operator
- Creating Shorthand/Literal Values from Constructors
- Primitive (a.k.a. Simple) Values
- The Primitive Values null, undefined, “string”, 10, true, and false Are Not Objects
- How Primitive Values Are Stored/Copied in JavaScript
- Primitive Values Are Equal by Value
- The String, Number, and Boolean Primitive Values Act Like Objects When Used Like Objects
- Complex (a.k.a. Composite) Values
- How Complex Values Are Stored/Copied in JavaScript
- Complex Objects Are Equal by Reference
- Complex Objects Have Dynamic Properties
- The typeof Operator Used on Primitive and Complex Values
- Dynamic Properties Allow for Mutable Objects
- All Constructor Instances Have Constructor Properties that Point to Their Constructor Function
- Verify that an Object Is an Instance of a Particular Constructor Function
- An Instance Created From a Constructor Can Have Its Own Independent Properties (Instance Properties)
- The Semantics of “JavaScript Objects” and “Object() Objects”
-
2. Working with Objects and Properties
- Complex Objects Can Contain Most of the JavaScript Values as Properties
- Encapsulating Complex Objects in a Programmatically Beneficial Way
- Getting/Setting/Updating an Object’s Properties Using Dot Notation or Bracket Notation
- Deleting Object Properties
- How References to Object Properties Are Resolved
- Using hasOwnProperty, Verify That an Object Property Is Not From the Prototype Chain
- Checking If an Object Contains a Given Property Using the in Operator
- Enumerate (Loop Over) an Object’s Properties using the for in Loop
- Host Objects versus Native Objects
- Enhancing and Extending Objects with Underscore.js
- 3. Object()
-
4. Function()
- Conceptual Overview of Using Function() Objects
- Function() Parameters
- Function() Properties and Methods
- Function Object Instance Properties and Methods
- Functions Always Return a Value
- Functions Are First-Class Citizens (Not Just Syntax but Values)
- Passing Parameters to a Function
- this and arguments Values Available To All Functions
- The arguments.callee Property
- The Function Instance length Property and arguments.length
- Redefining Function Parameters
- Return a Function Before It Is Done (Cancel Function Execution)
- Defining a Function (Statement, Expression, or Constructor)
- Invoking a Function [Function, Method, Constructor, or call() and apply()]
- Anonymous Functions
- Self-Invoking Function Expression
- Self-Invoking Anonymous Function Statements
- Functions Can Be Nested
- Passing Functions to Functions and Returning Functions from Functions
- Invoking Function Statements Before They Are Defined (Function Hoisting)
- A Function Can Call Itself (Recursion)
- 5. The Head/Global Object
-
6. The this Keyword
- Conceptual Overview of this and How It Refers to Objects
- 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
- Controlling the Value of this Using call() or apply()
- Using the this Keyword Inside a User-Defined Constructor Function
- The this Keyword Inside a Prototype Method Refers to a Constructor Instance
-
7. Scope and Closures
- Conceptual Overview of JavaScript Scope
- JavaScript Does Not Have Block Scope
- Use var Inside Functions to Declare Variables and Avoid Scope Gotchas
- The Scope Chain (Lexical Scoping)
- The Scope Chain Lookup Returns the First Found Value
- Scope Is Determined During Function Definition, not Invocation
- Closures Are Caused by the Scope Chain
-
8. Function Prototype Property
- Conceptual Overview of the Prototype Chain
- Why Care About the prototype Property?
- Prototype Is Standard on All function() Instances
- The Default prototype Property Is an Object() Object
- Instances Created From a Constructor Function are Linked to the Constructor’s prototype Property
- Last Stop in the prototype Chain is Object.prototype
- The prototype Chain Returns the First Property Match It Finds in the Chain
- Replacing the prototype Property with a New Object Removes the Default Constructor Property
- Instances That Inherit Properties from the Prototype Will Always Get the Latest Values
- Replacing the prototype Property with a New Object Does Not Update Former Instances
- User-Defined Constructors Can Leverage the Same Prototype Inheritance as Native Constructors
- Creating Inheritance Chains (the Original Intention)
-
9. Array()
- Conceptual Overview of Using Array() Objects
- Array() Parameters
- Array() Properties and Methods
- Array Object Instance Properties and Methods
- Creating Arrays
- Adding and Updating Values in Arrays
- Length versus Index
- Defining Arrays with a Predefined Length
- Setting Array Length can Add or Remove Values
- Arrays Containing Other Arrays (Multidimensional Arrays)
- Looping Over an Array, Backwards and Forwards
- 10. String()
- 11. Number()
- 12. Boolean()
- 13. Working with Primitive String, Number, and Boolean Values
- 14. Null
- 15. Undefined
- 16. Math Function
- A. Review
- B. Conclusion
- Index
- About the Author
- Colophon
- Copyright
Product information
- Title: JavaScript Enlightenment
- Author(s):
- Release date: December 2012
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781449342883
You might also like
book
JavaScript on Things
JavaScript on Things is your first step into the exciting and downright entertaining world of programming …
book
DOM Enlightenment
With DOM Enlightenment, you’ll learn how to manipulate HTML more efficiently by scripting the Document Object …
book
Effective JavaScript: 68 Specific Ways to Harness the Power of JavaScript
“It’s uncommon to have a programming language wonk who can speak in such comfortable and friendly …
book
Pro JavaScript Techniques, Second Edition
Pro JavaScript Techniques is the ultimate JavaScript book for today's web developer. It provides everything you …