JavaScript Enlightenment


JavaScript Enlightenment aims to provide the reader with an accurate JavaScript worldview through an examination of native JavaScript objects and supporting nuances: complex values, primitive values, scope, inheritance, the head object, etc. The book solidifies your understanding of the language.

It was my intention to write a book to give the reader an accurate JavaScript worldview through an examination of native JavaScript objects and supporting nuances: complex values, primitive values, scope, inheritance, the head object, etc. I intend this book to be a short and digestible summary of the ECMA-262, Edition 3 specification, focused on the nature of objects in JavaScript.

If you are a designer or developer who has only used JavaScript under the mantle of libraries (such as jQuery, Prototype, etc), it is my hope that the material in this book will transform you from a JavaScript library user into a JavaScript developer.



Total pages:141
Author:Cody Lindley


Chapter 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 (aka 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 (aka 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 (aka instance properties)
  • The semantics between “JavaScript objects” vs. “Object() objects”
Chapter 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 vs. native objects
  • Enhancing & extending objects with Underscore.js
Chapter 3 – Object()
  • Conceptual overview of using Object() objects
  • Object() parameters
  • Object() properties and methods
  • Object() object instance properties and methods
  • Creating Object() objects using “object literals”
  • All objects inherit from Object.prototype
Chapter 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 & arguments values available to all functions
  • The arguments.callee property
  • The function instance length property & arguments.length
  • Redefining function parameters
  • Return a function before it is done (i.e. cancel function execution)
  • Defining a function (statement, expression, or constructor)
  • Invoking a function (function, method, constructor, or call() & apply())
  • Anonymous functions
  • Self-invoking function expression
  • Self-invoking anonymous function statements
  • Functions can be nested
  • Passing functions to functions & returning functions from functions
  • Invoking function statements before they are defined (aka function hoisting)
  • A function can call itself (aka recursion)
Chapter 5 – The Head/Global Object
  • Conceptual overview of the head object
  • Global functions contained within the head object
  • The head object vs. global properties and global variables
  • Referring to the head object
  • The head object is implied and typically not referenced explicitly
Chapter 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 keyword this inside a prototype method refers to a constructor instance
Chapter 7 – Scope & Closures
  • Conceptual overview of JavaScript scope
  • JavaScript does not have block scope
  • Use var inside of functions to declare variables and avoid scope gotchas
  • The scope chain (aka 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
Chapter 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 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)
Chapter 9 – Array()
  • Conceptual overview of using Array() objects
  • Array() parameters
  • Array() properties & methods
  • Array object instance properties & methods
  • Creating arrays
  • Adding & updating values in arrays
  • Length vs. index
  • Defining arrays with a predefined length
  • Setting array length can add or remove values
  • Arrays containing other arrays (aka multidimensional arrays)
  • Looping over an array, backwards and forwards
Chapter 10 – String()
  • Conceptual overview of using the String() object
  • String() parameters
  • String() properties and methods
  • String object instance properties and methods
Chapter 11 – Number()
  • Conceptual overview of using the Number() object
  • Integers and floating-point numbers
  • Number() parameters
  • Number() properties
  • Number object instance properties and methods
Chapter 12 – Boolean()
  • Conceptual overview of using the Boolean() object
  • Boolean() parameters
  • Boolean() properties and methods
  • Boolean object instance properties and methods
  • Non-primitive false boolean objects convert to true
  • Certain things are false, everything else is true
  • Working with Primitive String, Number and Boolean values
  • Primitive/literal values are converted to objects when properties are accessed
  • You should typically use primitive string, number, and boolean values
Chapter 13 – Null
  • Conceptual overview of using the null value
  • typeof returns null values as “object”
Chapter 14 – Undefined
  • Conceptual overview of the undefined value
  • JavaScript ECMA-262 edition 3 (and later) declares the undefined variable in the global scope
Chapter 15 – Math Function
  • Conceptual overview of the built in Math Object
  • Math properties and methods
  • Math is not a constructor function
  • Math has constants you cannot augment/mutate

Read/ Download

Download PDF


(c) 2012 Cody Lindley

Leave a Reply

Your email address will not be published. Required fields are marked *