The Fundamentals Flashcards

1
Q

What is an expression?

A

A fragment of code that represents a single value, e.g. “200 + 100”, “300”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a statement? What is their characteristic feature?

A
  • A fragment of code that tells the computer to do something.
  • They end in a semicolon
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a compound expression? Give an example

A
  • An expression that contains multiple smaller expressions
  • For example, “1 + 1”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a literal? Is “1 + 1” a literal?

A
  • A literal is an expression that directly corresponds to a value, like “5”
  • “1 + 1” is not literally the same as 2, so is not a literal
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The process of creating an identifier for a binding is called…

A

Declaration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are two kinds of binding that can occur in JavaScript?

A
  • Variable: value can change
  • Constant: value cannot change
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Assigning a value to a variable for the first time is called…

A

Initialisation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

List the keyword(s) that can be used to declare variables/constants

A

Constants: const
Variables: var & let

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

let Age = 5;
age = 7;
Age;

A

5 - JavaScript is case-sensitive with variable value assignment.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Naming convention for true variables versus self-created ones

A
  • True: ALL_CAPS_SNAKE_CASE
  • Self: camelCase
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

JavaScript increment/decrement operator syntax

A
  • Increment: ++
  • Decrement: –
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Prefix vs postfix increment/decrement

A
  • Prefix returns the new value immediately
  • Postfix completes the same operation, but it immediately returns the value before the change anyway
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the four main assignment operators?

A
  • += (add another other than one “++”)
  • -= subtract another other than one
  • *= multiply by second expression
  • /= divide by second expression
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What property can we use to find the length of a string?

A

.length (e.g. string.length;)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What’s the syntax difference between a method and a property

A
  • Property: .propertyName, like .length
  • Method: .methodName(), like slice()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which slice() argument is inclusive/exclusive

A

First: inclusive
Second: exclusive

17
Q

Which method can we use to remove white space from a string?

A

.trim()

18
Q

What is a template literal? What characters do we embed it in compared to normal? What syntax do we use to add an expression?

A
  • A string that evaluates any expressions in it
  • We enclose in backticks, expression
  • To add an expression, we enclose in ${expression}
19
Q

Undefined vs null

A
  • Undefined means empty; no useful value
  • Null means intentionally empty

Same functional use, different interpretation by the reader.

20
Q

What are the two kinds of JavaScript operators associated with booleans?

A
  • Logical: take/return booleans
  • Comparison: take other values, return booleans
21
Q

What are the three logical boolean operators? What are their JavaScript syntax?

A
  • And: &&
  • Or: ||
  • Not:
22
Q

Simplify !a && !b

What law is this?

A

!(a || b)

  • From “not a and not b” to “not a or b.”
  • This is De Morgan’s law
23
Q

=== operator vs == operator. What is the inverse of this?

A
  • == uses type coersion
  • === does not

Both return a boolean based on whether two expressions are/aren’t equal.

Inverses are != and !==; same deal

24
Q

Truthiness lets us coerce _________ values into _______ ones.

A

Coerce non-boolean values into booleans.

25
Q

“cat” < “dog”;

Answer and explain

A

True.

Alphabetical order substitutes for value.

26
Q

Generally speaking, what JavaScript values are falsy?

A
  • Empty strings
  • Zero
  • Null/undefined
27
Q

How do we check if a value is truthy? Why does this work

A
  • Use !! operator
  • First ! returns boolean inverse, second un-inverts
28
Q

How do && and || operators interact w/ non-booleans?

A
  • && returns the first falsy value it reads (L to R), or the final value if all are truthy
  • || returns the first truthy value it finds, or the last if all are falsy