Eloquent Javascript
Margaret W.N
Posted on October 4, 2020
More on the book. What i learnt today:
Closure:
being able to reference a specific instance of a local binding in an enclosing scope. A function that references bindings from local scopes around it is called a closure.
A pure function
a specific kind of value-producing function that not only has no side effects but also doesn’t rely on side effects from other code—for example, it doesn’t read global bindings whose value might change. A pure function has the pleasant property that, when called with the same arguments, it always produces the same value
Array Methods
includes()
- checks if a given value exists in the array.
shift()
- removes the first(zero index) item from an array.
unshift()
- adds a item at the front(zero index) of an array
indexOf()
- searches through the array from the start to the end and returns the index at which the requested value was found
lastIndexOf()
- searches through the array from the end(last item)
trim ()
- removes whitespace (spaces, newlines, tabs, and similar characters) from the start and end of a string
...
Spread Syntax - expands or spreads out an array, passing its elements as separate arguments.
Looping through arrays using let
item of
items.
for (let item of items) {
console.log(item);
}
Math Object functions
Math.floor()
- rounds down
Math.ceil()
- rounds up
Math.round()
- rounds to the nearest whole number
Math.abs()
- takes the absolute value of a number, Negates a negative.
What is JSON?
A serialization format. Serialization means converting to a a flat description.
Json Methods
JSON. parse()
Converts a JSON string to a JavaScript object
JSON. stringify()
Converts a JavaScript object to a JSON string
That's it for Day 80
I'll continue with the book tommorrow
Posted on October 4, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.