JavaScript Concepts Flashcards
What data type is returned by an arithmetic operation?
Number
What is string concatenation?
its when you combine strings using the + operator
What purpose(s) does the + plus operator serve in JavaScript?
for numbers, it acts as the addition operator. 2+ 3 = 5
for strings, it acts as a concatenator
What data type is returned by comparing two values < , > , === , etc )?
boolean, either true or false
What does the += “plus-equals” operator do?
it is a shortcut command.
if word += 5 is the same as word = word + 5
What is the purpose of variables?
to assign a value for later reference. var area = 3 * 2
How do you declare a variable?
by using the keywords var , let , const
How do you initialize (assign a value to) a variable?
by using the = sign
What does it mean to say that variable names are “case sensitive”?
if the cases in the variable name are not matched exactly, an error will show
What does the = operator mean in JavaScript?
it is used to set values of variables
How do you update the value of a variable?
by using the variable name then the equal sign, followed by new value
What are objects used for?
a collection of properties where those properties can have their own values
What are object properties?
they are variable names that are attached to the object and they can have their values. The values can be different types but the properties are strings.
Describe object literal notation.
var obj = { }
How do you remove a property from an object?
delete nameOfObject.PropertyToDelete
What are the two ways to get or update the value of a property?
dot notation or bracket notation
What data type is returned by an arithmetic operation?
Numbers, including NaN since its type is number
What is string concatenation?
when you condense 2 or more strings into 1 string using the + operator
What purpose(s) does the + plus operator serve in JavaScript?
for strings it will be used to concatenate
for numbers it is used to add
for string + number it will concatenate by turning the number into a string
What is a function in JavaScript?
a formula, can be customized by you to take 0, 1, or more arguments. It will return a value., if you do not use return it will return undefined
Describe the parts of a function definition.
function key word, function name, parenthesis, and parameters (optional)
Describe the parts of a function call.
function name followed by (arguments here) example. greet('tom')
When comparing them side-by-side, what are the differences between a function call and a function definition?
function definition is just the code that you wrote, it will not run until it is called with ()
What is the difference between a parameter and an argument?
parameters are used when a function is declared. argument are the values that are passed into the parameters when the function is called
Why are function parameters useful?
you can use them as variables, which gives way more flexibility to do stuff
What two effects does a return statement have on the behavior of a function?
1) it ENDS the function when the JS engine finishes the return statement line
2) it returns a value from the function
What are arrays used for?
to have a collection of data by an ordered list, starting at index 0
Describe array literal notation
var = [] empty brackets mean array literal
How are arrays different from “plain” objects?
arrays do NOT have a property name and value. They have an index and a value. But like object, the value can be any type aka functions, objects, another array, number, string, etc