JavaScript Senior Flashcards
What is “string interpolation”?
Substituting part of a string with javascript variables
What is the syntax for writing a template literal?
Strings ${JS variables}
What is a code block? What are some examples of a code block?
Code between two curly braces (function, conditional, loop)
What does block scope mean?
Variable only exists in between the curly braces of the block
What is the scope of a variable declared with const or let?
Block-scoped
What is the difference between let and const?
Let – the variable can be reassigned
Const- cannot be reassigned
Why is it possible to .push() a new value into a const variable that points to an Array?
The const variable refers to the Array it refers to, not the actual values in the array
How should you decide on which type of declaration to use?
Const – if the value will always be the same
Let – if you have to reassign a value, use let
Prefer Const- use const, until you have to use let
What is destructuring, conceptually?
Take elements from an array or properties from an object and assign each to their own variable.
What is the syntax for Object destructuring?
const/let [ ] or { }
const [propertyName: newVarName, property2: varName2] = array
What is the syntax for defining an arrow function?
let/const varName = ( ) => { }
- parameter ( ) are optional if there is one parameter
- curly braces required if there is a statement
When an arrow function’s body is left without curly braces, what changes in its functionality?
If there are no curly braces, the code has to be an expression that evaluates to a single value.
How is the value of ‘this’ determined within an arrow function?
In an arrow function, ‘this’ is being determined when the arrow function is being defined. The value of ‘this’ is based on the value of ‘this’ in it’s parent code block. If parent is an arrow function as well, keep going up.
Shadowing
Inside an inner function, if a variable with the same name is declared as a variable in the outer function, the inner variable is the one accessed in that inner function and the outer variable cannot be accessed
CLI
Command Line Interfaces
What is Node.js?
Node.js is JavaScript that is not run in the browser.
What can Node.js be used for?
Used to build-back ends for web applications, command line programs, automation
What is a REPL?
Read-Evaluate-Print-loop
Takes a single user input, executes them, and prints them.
What back end languages have you heard of?
JavaScript. Python. PHP. Perl. Java. Ruby. C#
What is the difference between JavaScript and other back end languages?
JavaScript has the event loop.
What is a computer process?
A computer process is the instance of a computer program that is being executed by one or more threads.
Why should a full stack Web developer know that computer processes exist?
Full Stack Web Developers make multiple process work together to create one application.
What is the process object in a Node.js program?
It is a global object that provides info about, and control over current Node.js process
How do you access the process object in a Node.js program?
You can just call the ‘process’ object since it is a global variable.