Data Types
Primitive Values
&
Object References
Variable and Data
let user = “andrew”
Keywords let num = 32; Data Types
• Strings
let arr = [1,2,3,4,5]; • Number
Variable Name
• Array
let myCar ={ • Object
name: “Honda”,
year : 2008;
color : “yellow”};
What is a Data and Data Type ?
• Data is a value or a piece of information that is stored inside a
variable.
• Different types of Data that we can store in variable are called as data
types.
• String, Number, Boolean, Object, Array, and Function Undefined and
Null data type.
• The data types can be categorised in two : Primitives & Object
References.
Data Types – Primitives & Object References
• In JS, the values that we declare in a variable can be categorized as
primitive and object references.
• Primitives are immutable, that is once the values are declared they
can’t be altered or manipulated.
• We should not confuse the immutable values with the values
declared in variable. The value of a variable can be changed or
reassigned.
• On the other hand, values in object references can be altered,
manipulated or updated.
Data Types
Primitive Data Types Object References
• Null • Objects
• Undefined • Functions
• Boolean • Arrays
• String • Sets
• Number • Maps
• BigInt • WeakSets
• Symbol • WeakMaps
Primitive Data Types
• Boolean Type : It can have only 2 values True | False.
• Null Type : It has exactly 1 value null.
• Undefined Type : It’s a default value of all variable that are initialized but are not
assigned any value undefined.
• Number Type : All numeric values like 2, -3 (Integers), 3.145 (Floats) are all valid
number data types. Also there are symbolic values in JS, like +Infinity, - Infinity
and NaN.
• BigInt Type : This type is somewhat similar to number type but not exactly
same. There is safe number limit in JS ranging from -(2^53 − 1) and 2^53 − 1. To
overcome this issue we have BigInt. It is made by appending “n” to numbers.
Primitive Data Types
• String Type : This data type represents the textual data that can be stored in a
variable. Like “Hello!”, “Andrew” or many other such values. Altering the values
of Stings doesn’t actually changes the original value.
• Symbol Type : A Symbol is a unique and immutable primitive value and may be
used as the key of an Object property
*Except for null and undefined, all primitive values have object equivalents
that wrap around the primitive values.
Object References
• Object References : In JavaScript, object is a mapping between keys and values. Keys are strings
(or Symbols), and values can be anything (strings, number, objects, arrays etc.). Also We can say,
objects can be seen as a collection of properties.
• There are two types of object properties: The data property and the accessor property.
• Data Property : Associates a key with a value, [[Value]], [[Enumerable]], [[Writable]] and
[[Configurable]].
• Accessor Property : Associates a key with one of two accessor functions (get and set) to retrieve
or store a value, [[Get]], [[Set]], [[Enumerable]], [[Configurable]].
• Types of Objects : Objects, Functions, Indexed Collection Array and Typed Arrays, Keyed
collections: Maps, Sets, WeakMaps, WeakSets.
Thanks !!!
Like, Share & Subscribe