Javascript-primitives-and-variables Flashcards
What is the purpose of variables?
give data permeance and something that we can look back at the data in the future.
How do you declare a variable?
using (var)
How do you initialize (assign a value to) a variable?
using the variable name and use = (equal sign) or using some assignment operator followed by a value.
What characters are allowed in variable names?
(no numbers in the beginning), no special characters except: $, and _
What does it mean to say that variable names are “case sensitive”?
very strict, everything needs to be exact! (lower case needs to be lower cased, and upper case needs to be used with upper cased!).
What is the purpose of a string?
To store characters (ie user’s username, etc…)
What is the purpose of a number?
To count, do math, and numerical data
What is the purpose of a boolean?
To use it for making decisions
What does the = operator mean in JavaScript?
to assign values into variables.
How do you update the value of a variable?
place new value and use the = to pertaining variable name. (except using Var).
What is the difference between null and undefined?
null (intentional/ from developers) is purposeful but undefined (from computer) is something that has no argument.
Why is it a good habit to include “labels” when you log values to the browser console?
- To see where log is coming from
2. Its easier to keep track and for the sake of other developers and debugging situations
Give five examples of JavaScript primitives.
- string
- number
- boolean
- null
- undefined.