ES6 Flashcards
What kind of typed language is JavaScript?
JavaScript is a dynamically typed language. The type of variable is infered from the value assigned to it.
What exactly are variables?
Boxes or containers for storing data. They are named containers and you can use the name to retrieve the value later.
Var, Let, Const
What is interpolation? How to do it in ES6?
You use backticks and also ${variableName}
What is let?
Let is very similar to var with the exception that the variable can not be redeclared after declaration var is also scoped to the nearest ‘function block’
Let is scoped to the nearest ‘enclosing block’ - which can be a smaller scope than a function block.
What is an escape character?
It’s a \ in JavaScript that indicates that the next character should not be read.
What are operators?
Operators are used to assign values, compare values, perform arithmetic operations and more.
Ternary, binary, unary
Ternary:
condition ? expr1 : expr2
Binary:
1 + 2
Unary Operators
a++
++a
What does a switch statement do? How about a do-while loop?
color = ‘red’;
switch(red){
color ‘green’:
console…break
default:
}
What is the purpose of a function?
Functions let you group a series of statement together to perform some task. Once a function is created, it can be reused over and over in your code. If you find yourself repeating statement in your code, then a function may be the answer to avoid that repetition. DRY - Don’t Repeat Yourself
Functions in javascirpt are first class objects…They can have properties and methods just like any other object. Where they DIFFERE< is in the fact that functions can be called
Explain hoisting in JavaScript
Declared (not assigned) variables are sent to the top. So are functions
How do you call an anonymous function?
let sayGreeting = function(){}
sayGreeting();
What is an IIFE?
Immediately Invoked Function Expression
A way to immediately run the function when the pointer/variable is called. So, you have
What is a fat arrow function?
1) () =>
2) one return statement, no code blocks
3) one parameter, no need to use ()
4) no need to type function
Explain the ‘this’ keyword
In JS, the thing called this, is the objec that ‘owns’ the JS code
The value of this, when used in a fucntion, is the objec that ‘owns’ the function
The value of this, when used in an object, is the object itself
What is an object? What are two ways to construct?
It is a value type that contains key value pairs inside {}
Keys are also known as properties
Everything that isn’t a primitive type is an object
What are some basic methods for an Array?
Pop, push, shift, unshift, concat, reverse, sort (remember you can put condition), slice (remember, slice does not include the last part of the argument,,,2,5 doesn’t not include 5