JavaScript is one of the core technologies of the modern web, enabling interactive and dynamic user experiences in web browsers. Its relevance has expanded significantly with the rise of Node.js, allowing developers to use JavaScript for server-side programming, making it a versatile and ubiquitous language for full-stack development.
Understanding JavaScript is essential for anyone interested in web development, from creating simple website interactions to building complex single-page applications and server infrastructures.
About the book
Eloquent JavaScript serves as a comprehensive introduction to programming using the JavaScript language. The book is designed for beginners with no prior programming experience, guiding them from foundational concepts to more advanced topics.
It takes a practical, example-driven approach, immersing readers in writing code from the very start, with exercises and projects to reinforce learning.
What you will learn
Readers will gain a solid understanding of the JavaScript language’s fundamental structure, including its syntax, data types, and operators. The book covers core programming concepts such as control flow, functions, and data structures like objects and arrays.
You will learn about functional programming with higher-order functions, object-oriented programming with prototypes and constructors, and practical skills like error handling, debugging, and working with regular expressions. The included project chapters provide hands-on experience in applying these concepts to build programs.
Table of contents
On programming Why language matters What is JavaScript? Code, and what to do with it Overview of this book Typographic conventions
- Values, Types, and Operators
- Values
- Numbers
- Strings
- Unary operators
- Boolean values
- Undefined values
- Automatic type conversion
- Summary
- Program Structure
- Expressions and statements
- Variables
- Keywords and reserved words
- The environment
- Functions
- The console.log function
- Return values
- prompt and confirm
- Control flow
- Conditional execution
- while and do loops
- Indenting Code
- for loops
- Breaking Out of a Loop
- Updating variables succinctly
- Dispatching on a value with switch
- Capitalization
- Comments
- Summary
- Exercises
- Functions
- Defining a function
- Parameters and scopes
- Nested scope
- Functions as values
- Declaration notation
- The call stack
- Optional Arguments
- Closure
- Recursion
- Growing functions
- Functions and side effects
- Summary
- Exercises
- Data Structures: Objects and Arrays
- The weresquirrel
- Data sets
- Properties
- Methods
- Objects
- Mutability
- The lycanthrope’s log
- Computing correlation
- Objects as maps
- The final analysis
- Further arrayology
- Strings and their properties
- The arguments object
- The Math object
- The global object
- Summary
- Exercises
- Higher-Order Functions
- Abstraction
- Abstracting array traversal
- Higher-order functions
- Passing along arguments
- JSON
- Filtering an array
- Transforming with map
- Summarizing with reduce
- Composability
- The cost
- Great-great-great-great-…
- Binding
- Summary
- Exercises
- The Secret Life of Objects
- History
- Methods
- Prototypes
- Constructors
- Overriding derived properties
- Prototype interference
- Prototype-less objects
- Polymorphism
- Laying out a table
- Getters and setters
- Inheritance
- The instanceof operator
- Summary
- Exercises
- Project: Electronic Life
- Definition
- Representing space
- A critter’s programming interface
- The world object
- this and its scope
- Animating life
- It moves
- More life forms
- A more lifelike simulation
- Action handlers
- Populating the new world
- Bringing it to life
- Exercises
- Bugs and Error Handling
- Programmer mistakes
- Strict mode
- Testing
- Debugging
- Error propagation
- Exceptions
- Cleaning up after exceptions
- Selective catching
- Assertions
- Summary
- Exercises
- Regular Expressions
- Creating a regular expression
- Testing for matches
- Matching a set of characters
- Repeating parts of a pattern
- Grouping subexpressions
- Matches and groups
- The date type
- Word and string boundaries
Book details
- Title: Eloquent JavaScript
- Author(s): Marijn Haverbeke
- Main category: Programming
- Subcategory: JavaScript
- Language: English
- License: Creative Commons attribution-noncommercial license (CC BY-NC)
More books in: JavaScript, Programming
Legal notice: This book is shared for educational purposes only. The content is distributed under Creative Commons licenses or with explicit permission from the author. FreeProgrammingBooks may host files that comply with their respective licenses.