Basics Flashcards
What’s exponent operator?
**
What’s the difference between == and ===?
Strict equality (no attempt at type conversion)
What are the three methods for declaring strings?
’ ‘, “ “, ` `
How do you add quotation marks inside a string?
with the \ (escape) character
What are commonly used escape characters in strings?
Code Output \' single quote \" double quote \\ backslash \n newline \r carriage return \t tab \b word boundary \f form feed
What does it mean to say string values are immutable?
They cannot be altered once created, only assigned a new string.
Not allowed: var myStr = "Bob"; myStr[0] = "J";
What is the scope of variables assigned without the var keyword?
global
What happens when a local and global variable have the same name?
the local variable takes precedence
What’s the syntax for a switch statement?
switch(lowercaseLetter) { case "a": console.log("A"); break; case "b": console.log("B"); break; }
How are case values in a switch statement evaluated?
with strict equality
How do you execute a case in a switch statement if no matching values are found
with default
What does break do in switch statements?
tell javascript to stop executing statements
What’s the syntax for a switch statement that has multiple inputs with the same output?
switch(val) { case 1: case 2: case 3: result = "1, 2, or 3"; break;
What are the two ways to access object properties?
There are two ways to access the properties of an object: dot notation (.) and bracket notation ([])
What’s the syntax for declaring an object?
var myObj = { prop1: "val1", prop2: "val2" };
When would you use dot notation to access an objects properties?
When you know the key name and it has no spaces.