JavaScript Flashcards
(160 cards)
JavaScript-Primitives-and-Variables
What is the purpose of variables?
To store data or information so that we can use those data or information later.
JavaScript-Primitives-and-Variables
How do you declare a variable?
Write a variable keyword and a variable name. For example, var FullName;
JavaScript-Primitives-and-Variables
How do you initialize (assign a value to) a variable?
Use the equal sign(=) as an assignment operator
JavaScript-Primitives-and-Variables
What characters are allowed in variable names?
The name can contain letters, numbers, dollar sign($) or an underscore. But you cannot start with numbers.
JavaScript-Primitives-and-Variables
What does it mean to say that variable names are “case sensitive”?
If two variables are the same words but one has upper-case and other one has lower-case, it becomes different variables.
JavaScript-Primitives-and-Variables
What is the purpose of a string?
Strings can be used when working with any kind of text
JavaScript-Primitives-and-Variables
What is the purpose of a number?
Numbers can be used to calculate, determine the size of the screen, moving the position of an element on a page or setting the amount of time an element should take to fade in.
JavaScript-Primitives-and-Variables
What is the purpose of a boolean?
-To make decisions. For example, yes or no, turn switch on or off.
JavaScript-Primitives-and-Variables
What does the = operator mean in JavaScript?
is assignment operator. Assign value to the variable
JavaScript-Primitives-and-Variables
How do you update the value of a variable?
Assign new variable value
JavaScript-Primitives-and-Variables
What is the difference between null and undefined?
undefined means that the property has not been defined yet. Whereas, null means that the property has been defined but is empty. Null is intentionally not defined value. For example, null is like a parking lot where you can fill it in later, and undefined is an empty field.
JavaScript-Primitives-and-Variables
Why is it a good habit to include “labels” when you log values to the browser console?
Help others and myself where these values are coming from. Benefit others and yourself in the future
JavaScript-Primitives-and-Variables
Give five examples of JavaScript primitives.
Null, String, Number, Boolean, undefined
JavaScript-Operator-and-expressions
What data type is returned by an arithmetic operation?
Number
JavaScript-Operator-and-expressions
What is string concatenation?
Combine two or more strings to create one new string
JavaScript-Operator-and-expressions
What purpose(s) does the + plus operator serve in JavaScript?
Add one value to another or concatenate strings
JavaScript-Operator-and-expressions
What data type is returned by comparing two values (, ===, etc)?
Boolean
JavaScript-Operator-and-expressions
What does the += “plus-equals” operator do?
It is the additional assignment operator that adds the value of the right operand to a variable and assigns the result to the variable.
JavaScript-Objects
What are objects used for?
Associated with information to describe to a group of a lot of information together
The object is to model a real-world object.
JavaScript-Objects
What are object properties?
Key and value
Variables attached to an object
JavaScript-Objects
Describe object literal notation.
Variable keyword, variable name, assignment operator, opening curly brace, key and values and closing curly brace.
JavaScript-Objects
How do you remove a property from an object?
Use the delete keyword. For example, delete hotel.name;
JavaScript-Objects
What are the two ways to get or update the value of a property?
Use dot notation or square brackets
JavaScript-Arrays
What are arrays used for?
To store a list of values