Non-primitive data types are referred to complex structures that can store and organize multiple values.
There are 3 types of reference Data Values:
1. Object
2. Array
3. Function
An object is a collection of key-value pairs, allowing you to create complex data structures and models. Keys (properties) can be strings or symbols, and values can be any data type.
let object_variable = {
key1: value1,
key2: value2,
// Additional key-value pairs
};
let myobject = {
userName: "Wasif",
age: 21,
}
An array is an ordered list that can hold multiple values. Each value in the array element is identified by an index, starting from 0.
let array_variable = [value1, value2, value3];
let array_name = [value1, value2, value3];
A function is a block of reusable code that can be invoked with different arguments. Functions can return values and are a fundamental building block in JavaScript.
function function_name(paraMeter){
// code
}
function product(){
let a = 3;
let b = 4;
let product = a * b;
}
Modifying the value through one reference affects all references pointing to the same object..