What does a data type describe?
A data type describes what kind of value a program uses and which operations are valid for that value.
Study 03 Types and Data Representation with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What does a data type describe?
A data type describes what kind of value a program uses and which operations are valid for that value.
What is a primitive value?
Primitive values are single, immutable values, such as numbers, strings, Booleans, undefined, null, bigints, and symbols.
How do object variables differ from primitive variables?
Objects are reference values: variables hold references to objects, so assigning one object variable to another can make both names refer to the same object.
What limitation does a shallow object copy have?
A shallow copy copies an object's top-level properties, but nested objects or arrays may remain shared between the original and the copy.
What is explicit type conversion?
Explicit conversion is requested by the programmer, such as Number(text), String(value), Boolean(value), or parseFloat(text).
What is implicit conversion?
Implicit conversion, or coercion, happens automatically. For example, if one operand of + is a string, JavaScript performs string concatenation.
What does NaN represent?
NaN is a special numeric value indicating an unsuccessful numeric result, such as Number("not a number").
How do === and == differ?
The === operator checks strict equality without ordinary type conversion, while == permits type conversion before comparing.
How should JavaScript code check for null?
typeof null returns "object" because of a historical JavaScript behavior. Test for null directly with value === null.
How can code identify an array reliably?
Use Array.isArray(value) to distinguish an array from other objects, because typeof an array returns "object".
What are two important properties of JavaScript strings?
JavaScript strings are immutable, zero-indexed sequences of text. String methods return new strings instead of changing the original.
How should arrays, objects, sets, and maps be chosen?
Use an array for an ordered sequence, an object for named fields, a set for unique values, and a map for key-value lookup.