Fundamentals 1: variables & numbers Flashcards
What is a variable?
“storage containers” for data in your code
3 keywords to declare a variable
let
const
var
Which of the three variable declarations should you avoid and why?
let and const are newer
var can cause unexpected output
Identifying some naming conventions for variables in JS
use camelCase
no reserved words (keywords)
use english (for future posterity)
meaningful - they indicate what value is stored inside
Naming conventions: what can variable names contain?
only letters
digits
symbols ($, _)
What are operators, operands, and operations?
operands are the data acted upon by the operators
operators: mathematical symbol that indicate how data should be treated (x = / * etc)
operations: the calculation that happens
Explain the difference between prefixing and postfixing increment/decrement operators
prefix - when increment/decrement operator comes before
++count
returns the count after crementing is applied
postfix - when increment/decrement operator comes after
count++
returns the final count before crementing is applied
still quite confused by this
Unary vs binary operation?
unary - one operand
binary - two operands
What will produce a NaN result?
computational error, incorrect or undefined mathematical operation
trying to perform any further operations on NaN will still yield NaN
Which math operation with NaN will produce a result?
NaN * 0 = 1
how to check if a value is NaN
?
isNaN()
What does it mean when we call javascript a dynamically typed language?
variables and data types are not bound to each other