Javascript Flashcards
What does = operator do in Javascript?
It is the assignment operator typically used for variables
Which keyword is used to declare a variable in Javascript?
var
Which characters is a Javascript variable allowed to begin with?
- Uppercase letters
- lowercase letters
- underscore
- dollar sign
- numbers (cannot use numbers in the beginning of the variable however)
What are quotation marks used for in Javascript?
Used for string variables
What is the purpose of strings in Javascript?
Storing and manipulating text
What is the purpose of booleans in Javascript?
To find out if an expression is true or false
What is the purpose of numbers in Javascript?
Sets up a basis of counting and quantifies any math related value
What does null mean in JavaScript?
Intentional absence in value
What data types can object properties hold?
They can basically hold any variable like strings, numbers, booleans, etc
Describe the syntax (structure) of object literals in JavaScript?
var variableName = { key: 'value1' key2: 'value2' ];
What is the principal use of arrays?
Organized lists for variables that can be called upon
Describe the syntax (structure) of array-literals in JavaScript
var variableName = [value1, value2, value3];
What number represents the first index of an array?
0
How can you access the last element of an array?
(Length property of an array) subtract by 1
What are the five parts of a function definition?
function name(parameters) { code } - The function keyword, the name for a function (optional), the parameters, the code block, and the return statement(optional) - Function names can have letters, digits, underscores, and dollar signs
How do you call a function?
- Using the function name with the parentheses and semicolon
Example: myFunction();
What is the difference between a parameter and an argument?
Parameter - listed inside the parentheses in a function. Behave as local variables
Argument - values received by the function when it is invoked
What does strictly equal mean?
=== It means that the values being compared are of the same value and data type
What is the logical <b>and</b> operator?
Both statements have to be true in order to result in true.
Can you name some comparison operators?
== equal to === equal value and equal type != not equal !== not equal or not equal type > greater than < less than >= greater than or equal to <= les than or equal to
When is the first expression in the parentheses for a for loop (known as the initialization) evaluated?
The first expression (initialization) is used once before the code block is executed.
Typically written as (let i = 0).
Sets up the loop
When is the second expression in the parentheses for a for loop (known as the condition) evaluated?
The second expression (condition) is used to define the condition for executing the code block.
This is typically written as (i < number). The number representing how many times the loop will occur.
Lets computer know when to stop looping.
When is the third expression in the parentheses for a for loop (known as the final expression) evaluated?
The third expression (the final expression) is used to change the value each time the code block in the loop has been executed.
Can be written as (i++)
Helps to get the loop closer to stopping.
What is the purpose of the condition in a for loop?
Dictates when the loop will stop running.