Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. ## Eloquent JS Reflections
  2.  
  3. ### Chapter 1
  4.  
  5. Nothing too surprising here. The chapter does reveal some interesting nuances about JS:
  6. * Strings can be encased in quotes, double quotes or backticks
  7. * Null/undefined are mostly interchangeable and represent the absence of a meaningful value, while NaN represents the result of a nonsensical computation
  8. * JS is extremely flexible, and will make due with whatever input it's given (i.e. automatic type conversion)
  9.  
  10. In addition, there were some explanations of lower level concepts that I found helpful, like the reasoning behind inaccuracy in fractional numbers.
  11.  
  12. ### Chapter 2
  13.  
  14. I think the biggest takeaway here was the difference between defining bindings with let, const and var. I'm also taking away:
  15. * Syntax for conditional statements, while and for loops
  16. * Syntax for comments, both single and multi-line
  17.  
  18. ### Chapter 3
  19.  
  20. 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:
  21. * The differences between a side effect and a return value
  22. * Functions need an explicit `return` statement to return anything at all
  23. * Functions are extremely lax about the number of arguements passed to them
  24.  
  25. There were good refreshers on scope, the call stack and recursion as well.
  26.  
  27. ### Chapter 4
  28.  
  29. This chapter was an introduction to objects in JS. Some key points:
  30. * Methods are just properties that hold function values
  31. * Braces have two meanings in JS, denoting statement blocks and describing objects
  32. * Objects are mutable, other values (numbers, strings, and Booleans) are not
  33. * Rest parameters can be used to allow a function to receive any number of arguments
  34.  
  35. There was also a very detailed description of computing correlation, as well as a good refresher on JSON.
  36.  
  37. ### Chapter 6
  38.  
  39. 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:
  40. * JS does not implement public/private properties on its own, though they are typically denoted by using `_` as a prefix
  41. * Prototypes
  42. * In addition to their properties, most objects have a prototype (they can be created without one)
  43. * The prototype system in JS is an informal take on the class system found in other languages
  44. * A class is a constructor function with a prototype property
  45. * ES6 allows for class notation:
  46. ```
  47. class Rabbit {
  48. constructor(type) {
  49. this.type = type;
  50. }
  51.  
  52. speak(line) {
  53. console.log(`The ${this.type} rabbit says '${line}'`);
  54. }
  55. }
  56. ```
  57.  
  58. 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