JavaScript Flashcards
1
Q
Syntax: function
A
function functionName(params) {
};
2
Q
Syntax: print “Hello”
A
console.log(“Hello”)
3
Q
what does the var keyword do?
A
creates a variable in current scope
4
Q
Syntax: random number
A
Math.random() == 0-1
5
Q
Syntax: for loop
A
for (var counter = 1; counter < 6; counter++) { ; }
6
Q
Syntax: add to end of an array
A
array.push(‘end’);
7
Q
Syntax: while loop
A
while (true){
;
}
8
Q
== vs ===
A
=== is faster, because == does type conversions
9
Q
Syntax: do/while
A
do {
;
} while (condition);
10
Q
Math.floor()
A
rounds a number down to its nearest integer
11
Q
Syntax: If/else if/else
A
if () {
} else if () {
} else {
}
12
Q
isNaN()
A
returns true if arg is not a number, false if it is
13
Q
Syntax: switch
A
switch(val_to_check){ case 'string': ; break; default: ; }
14
Q
Syntax: constructing an instance of an object
A
var myObj = new Object();
15
Q
Syntax: Object constructor
A
function myObj(args) { this.args = args; this.myFunction = function() { }; }