Javascript Notes #2
Javascript Notes #2
A data type refers to the type of data that a javascript variable can hold. there
are seven primitive data types in JS
- string
- In any computer programming language, a string is a sequence of [characters]
(https://developer.mozilla.org/en-US/docs/Glossary/Character) used to represent
text.
- number
- In [JavaScript](https://developer.mozilla.org/en-US/docs/Glossary/
JavaScript), **Number** is a numeric data type in the [double-precision 64-bit
floating point format (IEEE
754)](https://en.wikipedia.org/wiki/Double_precision_floating-point_format)
- bigint
- In [JavaScript](https://developer.mozilla.org/en-US/docs/Glossary/
JavaScript), **BigInt** is a numeric data type that can represent integers in
the [arbitrary precision format](https://en.wikipedia.org/wiki/Arbitrary-
precision_arithmetic)
- boolean
- a **Boolean** is a logical data type that can have only the values true or
false.
- undefined
-
a [primitive](https://developer.mozilla.org/en-US/docs/Glossary/Primitive) value
automatically assigned
to [variables](https://developer.mozilla.org/en-US/docs/Glossary/Variable) that
have just been declared, or to formal [arguments](https://developer.mozilla.org/en-
US/docs/Glossary/Argument) for which there are no actual arguments.
- symbol
- a built-in object whose constructor returns a
Symbol [primitive](https://developer.mozilla.org/en-US/docs/Glossary/Primitive) —
also called a **Symbol value** or just a **Symbol** — that's guaranteed to be
unique. Symbols are often used to add unique property keys to an object that won't
collide with keys any other code might add to the object
- null
- represents a reference that points, generally intentionally, to a nonexistent
or invalid [object](https://developer.mozilla.org/en-US/docs/Glossary/Object) or
address.
- In [JavaScript](https://developer.mozilla.org/en-US/docs/Glossary/
JavaScript), null is marked as one of the [primitive
values](https://developer.mozilla.org/en-US/docs/Glossary/Primitive), because its
behavior is seemingly primitive. However, when using the typeof operator, it
returns “object”.
Object
- JS object is a data structure that allows us to have key >> value pairs
- So we can have distinct keys and each key is mapped to a value that can be of any
JS data type
- Built-in objects or “global objects”, are those built into the language
specification itself.
- There are numerous built-in objects within the JS language all of wich are
accessable at the global scope.
- Number
- Math
- Date
- String
- Error
- Function
- Boolean
- [More](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/
Global_Objects)
- TypeOf Operator
- You can use the typeOf opertator to find the data type of a JS variable it
returns a string indicating the type of provided
[operand’s](https://developer.mozilla.org/en-US/docs/Glossary/Operand) value
Prototypes