Types and Grammar Flashcards
What is a type?
A type is an intrinsic build in set of characteristics that uniquely distinguishes the behavior
Javascripts built in types (7)
null undefined boolean number string object symbol
Except for objects, all JS types are called:
Primitives
Function is what type?
object. Specifically a “callable object”
function.length returns
the number of formal parameters is it declared with
Array is what type?
A subtype of object
typeof [“d”,”a”]
object
var a;
typeof a
undefined
undefined vs undeclared
Undefined has been defined in accessible scope but not defined. Undeclared hasn’t been declared.
var a = [] a["13"] = "hello"; What will happen?
a will be populated with undefined until a[13] which is hello
mutability of strings
immutable
mutability of arrays
mutable
with a decimal value of eg 0.42, is the 0 optional?
yes
With a decimal value of 42.30, is the 0 optional?
yes
Why is 0.1 + 0.2 == 0.3 false?
Binary floating point numbers are not exact. It’s actually like .300000000004. This is like a number epsilon.