Eloquent JavaScript was recommended to me by Leon from #100Devs. While I’ve been participating in a JavaScript study using The Modern JavaScript Tutorial, I had an itch to also read Eloquent JavaScript as a refresher and review.
Eloquent JavaScript TIL - Introduction to Chapter 1
Introduction
- At the beginning, computing had no programming languages - it only consisted of 0’s and 1’s
- The programmers had to configure a large array of on/off switches (which represented 0 and 1) with precision to run a program.
- Programming languages allows us to interact with the computer using syntax that seems more “human” and “readable” to us (e.g. storing data to a named variable, rather than memory location number is more memorable for us).
JavaScript
- Introduced in 1995 - originally as a way to add programs and interactivity to Netscape Navigator browser.
- ECMAScript Standard - the official documentation on the “how-to” of the JavaScript language.
- Difficult thing about updating and improving an actively used programming language - programs that used to work in previously now could break and cause errors.
Chapter 1 - Values, Types, and Operators
- Bits - anything that is two-valued, usually described as 0, 1.
- Computers have an entire ocean of bits -> to make sense of these bits, we separate into chunks of information (values).
Numbers
- JavaScript uses a fixed 64-bit chunk to store a single number value. Part of the bit chunk is used to represent negative/positive sign, as well as position of the decimal point.
- Because of the 64-bit limitation, many numbers such as those with fractions/decimals lose precision.
Strings
- Each character/letter is represented by a number per the Unicode standard.
- Each character represented is using 16-bits of memory.
Automatic type conversion
- When you are using an operator on the wrong type of value (e.g. adding a string to a number value) - JavaScript doesn’t give you an error. Rather, it automatically proceeds to type conversion, sometimes in ways that aren’t quite intuitive to us.
- When using
==
equality operator withnull
orundefined
, the result is onlytrue
when they are compared against each other (null == undefined
) - which is very weird to me. - If you want a precise equality comparison, use
===
which checks for value as well as type.