Javascript Flashcards
(17 cards)
Javascript
Variables
var dog; let dog = 'string'; const dog;
Javascript
How do you write the T/F boolean?
True
False
Javascript
The Abscense of a value
Null
Javascript
Undefined
A variable that does not yet have an assigned value
Javascript
For giant math
BigInt
Javascript
Symbol data type
const sym1 = Symbol(); const sym2 = Symbol("foo"); const sym3 = Symbol("foo"); sym2 != sym3
Guaranteed unique
Javascript
And
&&
Javascipt
Or
||
Javascript
Not
!
Javascript
Difference between == & ===
3 === will check for strict equality. 100 != "100" 2 equal objects will not be equal because they are different objects !== will check for strict inequality
Javascript
If Statements
if ('this' == false) { //do stuff } else if ('this' == 'cake') { // other stuff } else { // }
Javascript
Switch Statement
switch (place) { case 'first': // do stuff break; case 'second': // do stuff break; default: break; }
Javascript
For Loop
for (var i = 5; i > 0; i--) { console.log(i); }; console.log('Countdown finished!');
Javascript
While Loop
var i = 5; while (i > 0) { console.log(i); i = i - 1; }; console.log('Counting completed!');
Javascript
Functions
// A function that accepts two parameters function letterFinder(word, match) { // do stuff }
Javascript
Objects
var drone = { speed: 100, altitude: 200, color: "red" } var car = {}; car.color = "red"; car["color"] = "green";
Javascript
Fat Arrow Functions
var addValues = (x, y) => { return x + y } asyncFunction() .then(() => asyncFunction1()) .then(() => asyncFunction2()) .then(() => finish);
Arrow functions shine best with anything that requires this to be bound to the context, and not the function itself.
Despite the fact that they are anonymous, I also like using them with methods such as map and reduce, because I think it makes my code more readable. To me, the pros outweigh the cons.