Event an action that acts as a trigger for other actions
examples:
keys being pressed
buttons being clicked
page being scrolled
timeouts expiring
Event Loop is the model of execution that JS uses and is comprised of the call stack and a message queue
call stack is used to track the actively running tasks
message queue is used to store things that can’t be fulfilled yet because the stack is busy
Message Queue is used to track the handling of events
Messages are items enqueued into and dequeued out of a message queue
When a new event occurs, but the call stack is busy processing another command, a message for that event is enqueued or added to the back of the message queue
When the runtime is finished with its current command, the next message is dequeued or taken out of the front of the message queue and processed
We can receive user input in NodeJS through the terminal
We will be using the built-in NodeJS module, readline
readline.createInterface is a function that when invoked will return an interface used to output text to the terminal and receive input from the terminal
Identify JavaScript as a language that utilizes an event loop model
Identify JavaScript as a single threaded language
Describe the difference between asynchronous and synchronous code
Execute the asynchronous function setTimeout with a callback.
Given the function function asyncy(cb) { setTimeout(cb, 1000); console.log("async") } and the function function callback() { console.log("callback"); }, predict the output of asyncy(callback);
Use setInterval to have a function execute 10 times with a 1 second period. After the 10th cycle, clear the interval.
Write a program that accepts user input using Node’s readline module