06.07.2017 Views

Mastering JavaScript

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Table of Contents<br />

The eval() method is evil 39<br />

The strict mode 39<br />

Running JSHint 41<br />

Summary 43<br />

Chapter 2: Functions, Closures, and Modules 45<br />

A function literal 46<br />

A function declaration 46<br />

Functions as data 49<br />

Scoping 50<br />

Global scope 51<br />

Local scope 52<br />

Function-level scope versus block-level scope 52<br />

Inline function expressions 56<br />

Block scopes 56<br />

Function declarations versus function expressions 58<br />

The arguments parameter 60<br />

The this parameter 61<br />

Invocation as a function 61<br />

Invocation as a method 61<br />

Invocation as a constructor 63<br />

Invocation using apply() and call() methods 63<br />

Anonymous functions 64<br />

Anonymous functions while creating an object 64<br />

Anonymous functions while creating a list 64<br />

Anonymous functions as a parameter to another function 65<br />

Anonymous functions in conditional logic 65<br />

Closures 66<br />

Timers and callbacks 69<br />

Private variables 69<br />

Loops and closures 70<br />

Modules 71<br />

Stylistic considerations 72<br />

Summary 73<br />

Chapter 3: Data Structures and Manipulation 75<br />

Regular expressions 76<br />

Exact match 77<br />

Match from a class of characters 77<br />

Repeated occurrences 81<br />

Alternatives – OR 84<br />

Beginning and end 84<br />

[ ii ]<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!