Skip to content

Instantly share code, notes, and snippets.

@MillsProvosty
Last active September 28, 2019 20:02
Show Gist options
  • Save MillsProvosty/7f971bd0f652d2bf9ee34a88a6361740 to your computer and use it in GitHub Desktop.
Save MillsProvosty/7f971bd0f652d2bf9ee34a88a6361740 to your computer and use it in GitHub Desktop.
Eloquent JavaScript Summaries
Chapter 1:
JavaScript uses basically the same values as Ruby: Strings, Booleans, Numbers and Undefined Values. The operators are also almost exactly the same as in Ruby. The biggest difference I niteced was the === and the !===. These are used when you do not want any automatic type conversions to happen- === tests if a value is precisely equal to the value on the opposite end.
Chapter 2:
Statements, expressions, bindings and functions are tools used to produce values. Statments generally contain expressions, and can have multiple smaller expressions encapsulated within them. You can interrupt a statement, similarly to Ruby, with conditionals like, if, else and switch, or with looping like while, do and for.
Bindings, or variables, are used to save state. You assing a value to a binding using the = operator. The Let binding can be changed as soon as it's reassigned. The Var is used similarly, but they didn't go into too much detail as apparently using var brings with it some confusing properties. Const stands for constant and will hold the value it's assigned to as long as that constant lives. Functions encapsulate a section of program. They seem to be very similar to Ruby's methods.
Chapter 3:
Functions are JavaScripts version of Methods. You must use the keyword 'function' to create one. It's important to bare in mind a functions scope- where it's defined impacts where it can be called. Functions are used to clean up code- either name functionality that's used over and over (to dry up your code), or name it first and define the code you need.
Chapter 4:
Objects and arrays are used to group values into one container of values. You can access the properties of a value by calling value.prop. Arrays in JavaScript share the same properties, and several of the same or very similar methods as in Ruby, such as .length, .indexOf, .slice.
Chapter 5:
Higher Order Functions can pass values from functions to other functions (that's a lot of functions!). Arrays come with their own methods like forEach or Mapping -very similar to iterating through ruby arrays. Some of the main methods discussed in this chapter were map, forEach, reduce (or fold), some, join, countBy and findIndex.
Chapter 8:
Debugging: I wish they had given more examples of debuggers to user, or some commonly used ones. Exceptions are particularly helpful. Catch catches exeptions and verifies that it's actually the expected kind of exception and what to do with it. Finally blocks can be used to ensure a piece of code always runs when a block finishes. Strict mode will catch portions of code that might be failing silently.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment