intro to Javascript Flashcards
(121 cards)
let name = null:
TYPEOF//
object
3 reference types
objects
arrays
funtions
let colors = {“blue, “green’}
typeof colors
object
function greet (name){
console.log(“hello” + name)
}
name is called a ____
parameter
default value of variables
undefined
an EXPRESSION produces __
a value
let x = 10 console.log(++x)//
console.log(x)
11
11
let x = 10 console.log(x++)//
console.log(x)
10
11
‘1’ === 1
false
strict operator compares _____ and ______
value and type
false || 1 || 2
1
operators go from left to right
two types of conditional statements
if…else
switch
when we need to repeat code we use ________
loops
name all the loops
for while do...while for...in for...of
let i = 0;
while (i <=10) { if (i % 2 === 0){ i++; continue; }
console.log(i);
i++;
}
RETURNS?
1 3 5 7 9
SHORTEN THIS
function isLandscape (width, height){ return (width > height) ? true : false; }
function isLandscape (width, height){ return (width > height); }
instead of writing “Not a number” you can use ___
NaN
typeof NaN //
number
In JavaScript, any function can return a new object. When it’s not a constructor function or class, it’s called a __________
factory function.
IN MODERN JS WHAT CAN BE CHANGED?
function createCircle(radius){ return { radius: radius, draw: function (){ console.log('draw') } };
}
make “radius: radius” to just “radius,:”
+++++++++
draw: (){
console.log(‘draw’)
}
};
function createCircle(radius){ return { radius: radius, draw: (){ console.log('draw') } }; }
create a new circle with radius of 14
let circle1 = createCircle(14)
what is Pascal notation?
when the first letter of every word is capitalized used in creating constructor functions
in JS a factory function uses the keyword _____ to create an object
return
function Circle(radius){ this.radius = radius;
}
ADD A DRAW FUNCTION
this.draw = function (){
}