Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Eloquent JS Reflections
- ### Chapter 1
- Nothing too surprising here. The chapter does reveal some interesting nuances about JS:
- * Strings can be encased in quotes, double quotes or backticks
- * Null/undefined are mostly interchangeable and represent the absence of a meaningful value, while NaN represents the result of a nonsensical computation
- * JS is extremely flexible, and will make due with whatever input it's given (i.e. automatic type conversion)
- In addition, there were some explanations of lower level concepts that I found helpful, like the reasoning behind inaccuracy in fractional numbers.
- ### Chapter 2
- I think the biggest takeaway here was the difference between defining bindings with let, const and var. I'm also taking away:
- * Syntax for conditional statements, while and for loops
- * Syntax for comments, both single and multi-line
- ### Chapter 3
- This chapter was all about learning how to write functions in JS. They're defined just like regular bindings, where the value of the binding is a function. The most interesting points to me were:
- * The differences between a side effect and a return value
- * Functions need an explicit `return` statement to return anything at all
- * Functions are extremely lax about the number of arguements passed to them
- There were good refreshers on scope, the call stack and recursion as well.
- ### Chapter 4
- This chapter was an introduction to objects in JS. Some key points:
- * Methods are just properties that hold function values
- * Braces have two meanings in JS, denoting statement blocks and describing objects
- * Objects are mutable, other values (numbers, strings, and Booleans) are not
- * Rest parameters can be used to allow a function to receive any number of arguments
- There was also a very detailed description of computing correlation, as well as a good refresher on JSON.
- ### Chapter 6
- This one was a real doozy. I think the biggest takeaway might be how convenient Ruby really is. Getting a little deeper, the chapter explains the pillars of OOP as they apply to JS. Some additional takeaways:
- * JS does not implement public/private properties on its own, though they are typically denoted by using `_` as a prefix
- * Prototypes
- * In addition to their properties, most objects have a prototype (they can be created without one)
- * The prototype system in JS is an informal take on the class system found in other languages
- * A class is a constructor function with a prototype property
- * ES6 allows for class notation:
- ```
- class Rabbit {
- constructor(type) {
- this.type = type;
- }
- speak(line) {
- console.log(`The ${this.type} rabbit says '${line}'`);
- }
- }
- ```
- I still need to do more research on the relationship between prototypes and constructors, as well as getters, setters and statics.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement