JavaScript Fundamentals Flashcards
What is a variable?
A container to store information or data
Why are variables useful?
Can reuse them, assign value to them
Readability
What two special characters can a variable begin with?
$
_
How do you declare a variable?
var variableName;
How do you assign a value to a variable?
Using the assignment operator (=)
Are variables case sensitive?
Yes
Which words cannot be used as variable names?
Any JS keywords
What is a string?
Form of data stored inside quotation marks
What is the string concatenation operator?
+
What is the difference when it comes to using single quotes or double quotes ( ‘ ‘ or “ “ )?
There is no difference, but must be consistent and use only one kind
How do you escape quotation characters?
\
What is type coercion?
Automatic conversion of values from one data type to another
What is a number in JavaScript?
Any number (integer and floating point)
What is an arithmetic operator?
Mathematical operators that can be used to calculate numbers
Name four of the arithmetic operators.
Addition Subtraction Division Multiplication Increment Decrement Modulo
What is the order of execution? (reference to mathematical operators)
Multiplication and division will come before addition and subtraction UNLESS you place addition and subtraction inside parentheses
What is a boolean?
Datatype of true or false
What is a comparison operator?
Compares two values and returns a boolean
What is the difference between undefined and null?
Undefined - absence of value
Null - intentional absence of value
What is a function?
Set of instructions to complete a task, reusable
Why are functions useful?
Reusable, don’t need to repeat yourself
How do you call a function?
functionName(arguments);
What are the parts of a function definition?
function functionName(parameters) { // code block }
What is the difference between a parameter and an argument?
Parameter - variables when declaring a function
Argument - what you pass in when calling or invoking a function
Why is it important to understand truthy and falsy values?
To understand how they can be used in conditionals and how it will affect the result/return value
Why is the typeof null an object?
Bug in JavaScript creation
Why do you always use === for comparisons?
To make sure the values being compared in data type and value
Do all if statements require an else statement?
No
What is the proper syntax for using the or operator?
condition1 || (dual pipes) condition2
Why do you want to avoid using == for comparison?
Type coercion, don’t let JavaScript decide what type to make the value
What is the primary use case for switches?
Checks an expression against multiple cases, then executes the code of a matching case
Does the default case have to be at the bottom of the switch statement?
No
What happens if there is no break statement between cases?
The next case will be executed even if the evaluation does not match the case
What is an object in JavaScript?
Grouping mechanism
Collection of related data to store key:value pairs & methods
How do you create an object literal?
var objectName = {} var objectName = new Object();
What is a property in relation to JavaScript objects?
They are variables on an object