JavaScript FreeCodeCamp Flashcards
// This is a comment
Single line comment
/* This is a multi-line comment */
multiple line comment
NaN
not a number
sometimes referred to as floating point numbers or floats
decimal numbers
myVar % 2 = 1
Checks to see if myVar is odd. 1 = odd, 0 = even
var sampleStr = “Alan said, "Peter is learning Javascript".”;
use \ to signal that “ should appear inside the string
\n
newline
\t
tab
\b
word boundary
\f
form feed
firstName.length
returns the number of characters in the string in firstName
zero-based indexing
programming languages start counting at 0
var lastLetter = firstName[firstName.length - 1];
returns the last character in the string firstName
multi-dimensional array
[[“Bulls, 23], [“White Sox”, 45]]
myArray[0] = 15;
arrays are mutable and entries can be changed freely
myArray[3][0][1]
equals the #3 entry, #0 entry in that array, and #1 entry in that array
myArray.push(4);
appends 4 to the end of the array
myArray.pop();
removes the last element from an array and returns that element