Basic Javascript Flashcards
What is a variable?
container to store data
Why are variables useful?
as a reference, to go and get that data
What two special characters can a variable begin with?
$ dollar sign and _ underscore
How do you declare a variable?
the var keyword
How do you assign a value to a variable?
= known as the assignment operator or equal sign
Are variables case sensitive?
Yes
Which words cannot be used as variable names?
function, var, if, else, switch, no numbers at the beginning. Basically keywords
What is a string?
sub series of characters enclosed by quotes
What is the string concatenations operator?
the plus sign
What is the difference when it comes to using single quotes or double quotes?
nothing
How do you escape quotations characters?
\ backslash
What is type coercion?
converting value from one type to another
What is a number in Javascript?
a data type
What is an arithmetic operator
math function that takes two operands and performs a calculation on them
Name four of the arithmetic operators
+ - * /
What is the order of execution?
(PEMDAS) mult and div before add and sub
What is a boolean?
true or false data type
What is a comparison operator?
comparing values to each other and resolve to a boolean
What is the difference between undefined and null?
humans assign null and undefined is accidental
What is a function?
block of code designed to perform a particular task
Why are functions useful?
to be more productive
How do you call a function?
with a parenthesis
What are the parts of a function definition?
function keyword, parameter list, code block, return
What is the difference between a parameter and an argument?
parameter is a named variable passed into a function, argument are the actual values passed to the function
Why is it important to understand truthy and falsy values?
to check conditionals
Why is the typeof an object null?
its a bug
What is the difference between null and undefined?
null is an assigned value and undefined means a variable has been declared but not defined yet
Why do you always use === for comparisons?
to not allow multiple different types of values or to make it more strict
Why do you want to avoid using == for comparison?
to not have variance in the code
Do all if statements require an else statement/
NO
What is the proper syntax for using the or operator?
|| dual pipes
What is the primary use case for switches?
allows a variable to be tested for equality against a list of values
Does the default case have to be a at the bottom of the switch statement?
it can be at any place within the switch
What happens if there is no break statement between cases?
the program continues to the next labeled statement.
What is an object in JS?
unordered collection of related data. a collection of properties and methods linked together
How do you create an object literal?
var object ={ }; var object = new Object( ); its the same thing
What is a property in relation to JS objects?
A place in which we store data inside on an object.
When should you use bracket notation over dot notation with objects?
bracket notations allows the use of characters that can’t be used with dot notation. Also when a property name is a variable
How do you remove a property from an object?
the delete operator deletes both the value of the property and the property itself.
What is an array?
used to store a collection of data
How do you create an array literal?
by using an enclosed square bracket
What are the keys for the values inside an array?
numbers counting up from zero
Arrays have a property named length. Because arrays have properties, what other data structure are they similar to?
objects
What are some good use cases for using objects inside arrays?
to remember the order of a series of objects. anything that involves a list of complex data