Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

README.md

JavaScript

I recently discovered "Eloquent JavaScript" by M. Haverbeke which seems to be a common introduction to both programming and JavaScript, e.g. for bootcamp students. So far, I followed a conservative philosophy of "the least amount of JS you can get away with" and thus my JS skills are limited:

Study goals:

  • Level-up JS skills, understand prototypic features
  • Learn and write modern JS instead of a mix of various language features/standards
  • Understand JS module system, dependency management, bundling and webpack
  • Get started with Node.js, learn basic API

My Learnings

(As a person with extensive programming and CS background, ymmv.)

1. Values, Types, and Operators

Calculations with whole numbers [...] smaller than the aforementioned 9 quadrillion are guaranteed to always be precise.

There is only one value in JavaScript that is not equal to itself, and that is NaN (“not a number”). NaN is supposed to denote the result of a nonsensical computation, and as such, it isn’t equal to the result of any other nonsensical computations.

2. Program Structure

3. Functions

4. Data Structures: Objects and Arrays

(nice phi coefficient example to measure correlation between two variables)

5. Higher-Order Functions

6. The Secret Life of Objects

this:

Prototypes:

Maps:

Polymorphism and Symbols:

Iterators:

Getters, setters, static:

Inheritance:

7. Project: A Robot

8. Bugs and Errors

  • Enable strict mode by writing the following line at the beginning of a file or function body:

    "use strict";
  • Strict mode reports:

    • Usage of undefined bindings (normally, they'd be created implicitly in global scope)
    • this will be undefined in function scope when the function is not used as a method (normally, this would then refer to global scope)
    • Defining function parameters with the same name
    • Removes with statement and other problematic language features
  • Calling constructors defined with class keyword without new will always result in an error

  • Use TypeScript

Debugging:

  • Inserting debugger statement will pause program execution when browser developer tools are open

Exceptions:

9. Regular Expressions (Summary)

Date:

  • Month numbers start at 0, day numbers at 1

String replace:

String search:

  • Like indexOf, but searching for first position matching pattern
  • Searching for lastIndex is tricky, y is "sticky" flag (= RegEx must be found starting at lastIndex, by default: from beginning of string)

Example: parse INI file

10. Modules

ini and dijkstrajs packages from NPM are mentioned.

  • setTimeout(callback, delayInMs)

Promises:

paused at https://eloquentjavascript.net/11_async.html#h_o8Vlf60I8f

  • Basics on TCP, client-server, URL structure, HTTP, HTML, how to include JS in HTML

Finding elements:

  • All element nodes have getElementsByTagName, e.g. document.body
  • document.getElementById
  • getElementsByClassName

Changing the document:

Styling/CSS:

Propagation

Default actions, e.g. right click is context menu, down arrow is scrolling down

  • JS event handlers are triggered before the default actions
  • Call preventDefault() on the event object

Key events

Event types

Web workers

Timers

Read the entire docs at https://nodejs.org/en/docs/

HTTP module

Streams

paused at https://eloquentjavascript.net/20_node.html#h_dJhdomfGgD

Further Reads