The Language Flashcards
What is this scientific notation equal to?
2.998e8
2.998 x 10^8 = 299,800,000
What result do you get when you try to calculate any number of other numeric operations that don’t yield a precise, meaningful result.
NaN.
What are the characters you get when you press enter?
Newlines
How do you escape a character?
\
How do you create a newline?
\n
How do you create a tab character?
\t
What does the typeof operator do?
Typeof produces a string value naming the type of the value you give it.
Can strings be compared using booleans?
Yes. Ex: console.log(“Aardvark”
Are uppercase letters “less than” or “more than” lowercase letters?
uppercase letters are always “less” than lowercase ones, so “Z”
What value in Javascript is not equal to itself?
NaN. console.log(NaN == NaN) // -> false
NaN is supposed to denote the result of a nonsensical computation, and as such, it isn’t equal to the result of any other nonsensical computations.
When is the logical “and” operator true?
console.log(true && false) // → false console.log(true && true) // → true
It is a binary operator, and its result is true only if both the values given to it are true.
When is the logical “or” operator true?
It produces true if either of the values given to it is true.
console.log(false || true) // → true console.log(false || false) // → false
What kind of operator is the “not” operator and what does it do?
Not is written as an exclamation mark (!). It is a unary operator that flips the value given to it—!true produces false and !false gives true.
How does precedence work with standard boolean operators?
|| has the lowest precedence, then comes &&, then the comparison operators (>, ==, and so on), and then the rest.
What is the “conditional” operator also called and how does it work?
Sometimes just called the “ternary” operator since it is the only such operator in the language). The value on the left of the question mark “picks” which of the other two values will come out. When it is true, the middle value is chosen, and when it is false, the value on the right comes out.
console.log(true ? 1 : 2); // → 1 console.log(false ? 1 : 2); // → 2