JavaScript Flashcards
How do you access the index n of an array?
array[n]
How do you compare if something is not equal to another?
!==
How do you add a single line comment?
// This would be a single line comment
How do you add a multi line comment?
/* This is a multi line comment, separated by newlines */
What is the command to print to the console for debugging?
console.log()
What is one syntax for function declaration?
var name = function(argument1, argument2) {
code goes here;
more code;
}
How would you call a function ?
name(argument1, argument2);
What is the syntax for an if-else statement?
if (condition) { code if condition is true; } else { code if condition is false; }
What is the syntax for a for-loop?
for ( var i = startValue ; i < endValue ; i+=stepValue ) { code to be looped through; }
Note: Remember the var i here can be anything really, but i is very common for a looping variable.