Javascript Flashcards
What Data Types does Javascript use?
boolean undefined string symbol object null number
Declare a variable “cats”
var cats;
variables cannot start with a number or contain spaces.
Which way does assignment go
right to left.
For example. Below, myVar gets defined as 5 and then myNum gets defined as myVar (which is currently 5).
myVar = 5; myNum = myVar;
what does NaN mean
Not a Number
happens when you use an undefined variable in an equation.
what does i++ operator do?
same thing as typing i=i+1
what does i– operator do?
same thing as typing i=1-1
What does the % operator do?
remainder
gives you the remainder of the numbers you are dividing.
4 % 3 = 1
used as a way of testing even and odd numbers. If you remainder anything by 2 it is even if the remainder is 0 and odd if the remainder is 1.
+= operator
does the assignment and addition in one step.
MyVar += 5 means that MyVar is 5 and that you should add 5 to it? I don’t entirely understand how this one works.
\n
new line
\r
carriage return (what is this?)
what is a carriage return
(figure it out)
\t
tab
\b
backspace
\f
form feed
What do you call it when a + operator is used with a string value
concatenation
Example:
var myStr =”This is the start.”+ “ This is the end.”
Output is: “This is the start. This is the end.
How do you count the number of characters in a string such as the following variable.
Then assign that length to another variable
var catName = “steve”
catNumber = catName.length;
The number would be 5 since that’s how many letters are in “steve.” So now catNumber would equal 5
Use bracket notation to assign the first letter of a last name as a variable to var firstLetterOfLastName.
var firstLetterOfLastName = ""; var lastName = "Lovelace";
firstLetterOfLastName = lastName[0];
in javascript, strings are “immutable” which means what?
Once a string is created it cannot be altered once created
What is the output of the following?
var name = "bob"; var letter = name[2];
b