The Fundamentals Flashcards
What is an expression?
A fragment of code that represents a single value, e.g. “200 + 100”, “300”
What is a statement? What is their characteristic feature?
- A fragment of code that tells the computer to do something.
- They end in a semicolon
What is a compound expression? Give an example
- An expression that contains multiple smaller expressions
- For example, “1 + 1”
What is a literal? Is “1 + 1” a literal?
- 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
The process of creating an identifier for a binding is called…
Declaration.
What are two kinds of binding that can occur in JavaScript?
- Variable: value can change
- Constant: value cannot change
Assigning a value to a variable for the first time is called…
Initialisation
List the keyword(s) that can be used to declare variables/constants
Constants: const
Variables: var & let
let Age = 5;
age = 7;
Age;
5 - JavaScript is case-sensitive with variable value assignment.
Naming convention for true variables versus self-created ones
- True: ALL_CAPS_SNAKE_CASE
- Self: camelCase
JavaScript increment/decrement operator syntax
- Increment: ++
- Decrement: –
Prefix vs postfix increment/decrement
- Prefix returns the new value immediately
- Postfix completes the same operation, but it immediately returns the value before the change anyway
What are the four main assignment operators?
- += (add another other than one “++”)
- -= subtract another other than one
- *= multiply by second expression
- /= divide by second expression
What property can we use to find the length of a string?
.length (e.g. string.length;)
What’s the syntax difference between a method and a property
- Property: .propertyName, like .length
- Method: .methodName(), like slice()