Thanks to a little time off and a trip across a few states, I was able to finish it.
I will not cover the book in-depth, but I wanted to present what I thought was interesting, or my "ah-ha" moment's I reached.
JS was built on good ideas and bad ideas, which I'll get to a little later. The good ideas, according to DC, are:
This is exactly why I love JS. I came from a background of PHP, C, and C++ where these weren't features except for functions,but they aren't first-class citizens, and the loosely typed nature of PHP.
I have always heard the term "immutable" and have never really found a definition that I could wrap my head around, or I just didn't try to (silly me).After this book and a little more digging it finally makes sense. Once an object, variable, etc. is made, memory is allocated for it. If you try to change it,the initial allocation is not altered; a new memory allocation is made even if you don't plan on using your initial creation. The garbage collector will cleanit up for you.
I like how there are a set number of "falsy" values, or values that equate to false. You can test these out by running
Boolean( value ).These falsy values include:
Everything else will equate to true. Try it out.
Everything except Numbers, Strings, Booleans, Null, and Undefined are objects.
You might argue that Numbers and Strings are objects, but they aren't. What makes them look like objects is the fact that they have access to String.prototypeor Number.prototype (primitive wrappers). This allows them to behave like an object even if they weren't initialized using a constructor (i.e. new).
When running the
hasOwnProperty function on an object, it will not look at the prototype chain. I know I've ran into some issues because of this before. Good to know.
newis not recommended when constructing objects with functions. Why?
return= "return control to part of the program that invoked the function"
thisto the global object instead of the newly created object
deleteleaves a hole,
Nothing too much to say here other than it was cool to see how methods like
splice and others are implemented. Makes me think more about using them.
I'm not going to tell you. If you really want to know you should read the book.
Basically, they are some things that you already probably know you shouldn't be using. But if you are using them, be sure to use them sparingly.