Q&A: Front End Fundamentals
Data Types
- number
3.14
- string
'yolo'
- Object
{ hi: 'hello'}
- function
function makeStuff(materials) { ... }
- boolean
false
Logic & Control Flow
var stuff = ['backpack', 'phone', 'watch'];
var modifiedStuff = stuff.filter(function(item) {
return item != null;
});
function doesUserHaveAge(num) {
if (parseInt(num) > 120) {
return false;
} else if (num) {
return true;
}
return false;
}
One Line Conditional
var stuff = false;
if (stuff) console.log('this function worked?');
prompt()
var userAnswer = prompt('What do you do?');
console.log(userAnswer);
What is a REPL?
- Reads input
- Evaluates input
- Processes your input
- Loops back to execute new commands
Running a File
node myFile.js
- Runs myFile.js
Objects
Loop Types
while()
for (var i = 0....)
for in
(for each)
array.forEach(function() { ... })
- this is the fastest to iterate over something
Comparison Operators!
> 1 == 1
true
> 1 == "1"
true
> 1 === "1"
false
> 1 !== "1"
true
>
Functions
Clean Code
HTML / CSS