1. The author expresses their love and hate for JavaScript, but realizes it is their own lack of understanding, not JavaScript itself, that is the issue.
2. The author received guidance on JavaScript concepts like the event loop, scope, functions, and how a better understanding of these core concepts can help overcome frustrations with asynchronous behavior and callbacks.
3. The response encourages the author to focus on understanding foundations, find a mentor, be a mentor to others, and provide clear guidance to help others learn.
13. <3
Declarative code tells the what.
Imperative tells the how.
Imperative code is more verobse verbose.xxxxxxx
Declarative vs Imperative
14. A real-life parallel in the imperative world would be
entering a bar for a drink, and giving the following
instructions to the bartender:
Take a glass fomr from the shelf
Put the glass in front of the draft
Pull down the handle until the glass is full
Pass me the glass
Imperative
xxxx
<3
15. In the declarative world, instead, you would just say:
“A coke, please.”
The declarative approach of asking asking for a drink
assumes that teh the bartender knows how to prepare it
Declarative
xxxxxx
xxx
<3
24. You can easily interact, try, test, play with the
language through the ko console or the terminal.
Your laptop will not get on fire…
Interactive
xx
<3
37. I started with C, Java, lots of PHP, a bit of JS, mainly
DOM manipulation.
Those languages had a HGU HUGE influence on me
I couldn’t be that expressive and declarative at the
beginning
:(
xxx
39. I was understanding the underlined concepts…
but I couldn’t apply them effectively in my code
:(
40. How do I return the response from an asynchronous call? 1m views
How do JavaScript closures work? 1.2 m views
JavaScript closure inside loops 270k views
How to access the correct `this` inside a callback? 131k views
What is the scope of variables in JavaScript? 509k views
How can I handle callback error in JavaScript with try/catch?
stackoverflow.com/questions/tagged/javascript?sort=frequent
:(
60. JavaScript is single thread.
It executes one thing at a time.
It has non-blocking I/O model (events, timers, network
calls, filesystem calls)
Event Loop
⇏
63. Only when I/O is involved
JS is non-blocking
⇏
“a-ha!”
64. JavaScript is single thread.
It executes one thing at a time.
It has non-blocking I/O model (events, timers, network
calls, filesystem calls).
Who makes the “concurrent model” possible?
Nodes has 4 threads and when possible uses libuv to deal
with I/O. Almost the same happens in the browser (i.e.
threads/libevent)
Event Loop
⇏
65. JavaScript is single thread.
It executes one thing at a time.
It has non-blocking I/O model (events, timers, network
calls, filesystem calls).
Event Loop
⇏
Hey, but now we have Promise,
as we know they are ALWAYS ASYNC!
How is it possible given the event loop model?
From ES6, you have a “mini event loop” in the language:
Jobs and Jsbs Jobs queuexxxx
67. In JavaScript, scope refers to the current context of
your code.
Each function creates its own execution context.
Scoping
⇏
68.
69. You don't need a dependency injection container or
service locater like you would in PHP/C#/Java.
Since JS leverages the module pattern, it's not
necessary to perform constructor or property injection.
Although you still can.
Scoping
⇏
70. Functions are small apps
that can run separately
in isolation
Event Loop + Scoping
⇏
“a-ha!”
73. First class citizen:
return a function from a function
pass a function as an argument to a function (HOF)
Functions are objects in JavaScript
Function
⇏
93. function expression
only defined when
that line is reached
function declaration
is defined as soon as
its surrounding
function or script is executed
94.
95.
96.
97. How do I return the response from an asynchronous call? 1m views
How do JavaScript closures work? 1.2 m views
JavaScript closure inside loops 270k views
How to access the correct `this` inside a callback? 131k views
What is the scope of variables in JavaScript? 509k views
How can I handle callback error in JavaScript with try/catch?
stackoverflow.com/questions/tagged/javascript?sort=frequent
:(