JS Operators & Misc Grammar Flashcards
delete Operator
delete person.age;
deletes a property from an object
in Operator
“firstName” in person
4 in array
returns true if the specified property is in the specified object, otherwise false
instanceof Operator
cars instanceof Array
returns true if the specified object is an instance of the specified object
break ?labelname;
use with label: Loop2: for (j = 10; j < 15; j++) { if (j === 12) { break Loop2; } }
exits a switch statement or a loop (for, for … in, while, do … while)
continue ?labelname
breaks one iteration (in the loop) if a specified condition occurs, and continues with the next iteration in the loop
debugger
enter debugging mode
do…while
creates a loop that executes a block of code once, before checking if the condition is true, then it will repeat the loop as long as the condition is true
for (statement 1; statement 2; statement 3) {
code block to be executed
}
creates a loop that is executed as long as a condition is true
for (var in object) {
code block to be executed
}
for (x in person) {
text += person[x];
}
loops through the properties of an object.
The block of code inside the loop will be executed once for each property.
return value;
stops the execution of a function and returns a value from that function
switch(expression) { case n: code block break; case n: code block break; default: default code block }
executes a block of code depending on different cases
while (condition) {
code block to be executed
}
creates a loop that is executed while a specified condition is true
Math.E
Returns Euler’s number (approx. 2.718)
Math.LN2
Returns the natural logarithm of 2 (approx. 0.693)
Math.LN10
Returns the natural logarithm of 10 (approx. 2.302)