General - Beginning Flashcards
Name Three ways to define variables in JavaScript
var, let, const
Give the definition of an “operator” in JavaScript.
An operator is a character or phrase that performs a task in our code.
typeof is an operator
(Arithmetic operators: + - * / %, etc)
In a general sense, what is a “property” of a data type in JavaScript
Property in regards to data types would be information automatically generated about the data type in question.
What is a method in JavaScript?
A method is a function that is a property of a Primitive Type or an Object.
How do we invoke or call a method in JavaScript.
Methods are attached to their Primitive Type or Object with the dot operator (.) and Empty Parenthesis ().
What are the 8 fundamental data types in JavaScript?
- String
- Number
- Boolean
- Null
- Undefined
- Symbol
- BigInt
- Object
What is a mathematical assignment operator?
Mathematical assignment operators are built-in operators in javascript that help with incrementation. For example:
+=
-=
*=
/=
What is the equivalent mathematical assignment operator to z = z + 1?
z += 1
What is the z *= 2 equivalent to without using a mathematical assignment operator?
z = z * 2
z = 5
z -= 1
z = ?
z = 4
z = 6
z /= 2
z = ?
z = 3
What is the increment operator in JavaScript and how is it used?
++
This mathematical assignment operator increase the value of something by 1
What does the following represent and what is its function?
–
This is the decrement operator.
The decrement operator is a mathematical assignment operator that decreases the value of something by 1
How can we check the type (data type) of a variable
We can use the ‘typeof’ operator in JavaScript.
console.log(typeof variableName)
What are the two broad types of Methods in JavaScript.
Instance Methods - methods called on an object instance
Static Methods - methods called on an object constructor, not on an instance.
What does it mean that JavaScript is weakly typed?
To be weakly typed means that we do not need to declare the type of data being stored in a variable.
What is a conditional statement in JavaScript
A statement that checks a certain condition and performs an action based on that condition
Give the syntax of an ‘if’ statement
if(condition){code block/block statement}
if condition evaluates to true, the code block will be executed
Where would we use an if…else statement
When we have a binary decision that can evaluate to true or false
What is the syntax of an else statement (assume the presence of an if statement)
else{code block/block statement}
when the if-statement evaluates to false the else code block will execute.
List the comparison operators
- < less than
- > greater than
- < = less than or equal to
- > = greater than or equal to
- === strictly equal to
- ! == not strictly equal to
What is the identity operator?
===