JAVASCRIPT Flashcards
What is the purpose of variables?
A script will have to temporarily store the bits of information it needs to do its job. It can store this data in variables.
Computers require more information than you think.
How do youdeclarea variable?
You need the variable keyword & variable name.
How do you initialize (assign a value to) a variable?
With the variable name, you need the assignment operator and variable value.
What characters are allowed in variable names?
Variable names can only contain letters, numbers, underscores, or dollar signs.
Variable name cannot start with a number.
What does it mean to say that variable names are “case sensitive”?
Capitalized letters vs lowercase letters are not the same value, meaning they make a difference and are “case sensitive”.
What is the purpose of a string?
Strings are made so that Javascript won’t read it as a code.
What is the purpose of a number?
Tasks that involve counting or calculating sums, numeric values.
What is the purpose of a boolean?
They are helpful when determining which part of a script should run.
What does the”=”operator mean in JavaScript?
It is the assignment operator. Assigns right operand value to left operand.
How do you update the value of a variable?
Re-write the new value on the right operand and declare it again.
The “var” keyword isn’t necessary for that second time.
What is the difference betweennullandundefined?
Null: It is the intentional absence of the value.
Null can’t be determined by Javascript.
Undefined: It meansthe value does not exist in the compiler.
Undefined can be determined by javascript.
Why is it a good habit to include “labels” when you log values to the browser console?
So you know what each value represents.
Easier for other people on your team who are also working on the same file.
Give five examples of JavaScript primitives.
String, number, boolean, null, undefined.
What data type is returned by an arithmetic operation?
A number data type.
What is string concatenation?
Joining together two or more strings to create one string, which is the string concatenation.
What purpose(s) does the”+”plus operator serve in JavaScript?
It can either add numbers, or join strings together like previous question.
It can also join variables together.
What data type is returned by comparing two values (,===, etc)?
A boolean data type.
What does the+=”plus-equals” operator do?
That operator adds the value of the right operand to a variable and assigns the result to the same variable on the left (this variable on the left will have a new value).
What are objects used for?
To keep a collection of related data, of primitive or reference types, in the form of “key: value” pairs.
What are object properties?
Properties are the values associated with a JavaScript object.
Describe object literal notation.
Opening and closing curly brace.
How do you remove a property from an object?
Use the delete operator.
“objectName”.”propertyName”
What are the two ways to get or update the value of a property?
Dot & Bracket Notation.
What are arrays used for?
When working on any kind of a list or with a set of values that are related to each other.