All About Array

 Class 1: An array is an object. Many values contain an array. So, the array is important in javascript.

Arrays Syntex- const=['value', 'value', 'value']

Also can be written- Const a=[7, "string", boollean]

Some example array codes-

                 let marks_class_12 = [91, 82, 63, 84, false, "Not Present"]

print this- console.log(marks_class_12)

individual track the number then code is:

console.log(marks_class_12[0])

console.log(marks_class_12[1])

console.log(marks_class_12[2])

console.log(marks_class_12[3])

console.log(marks_class_12[4])

console.log(marks_class_12[5])// index written rules. means position.

Here- 0, 1, 2, 3 array index that means position 

                          0-91

                          1-82

                          2-63

console.log(marks_class_12[6]) // Will be undefined because index 6 does not exist

 Anyone can define [6] then the code is 

 marks_class_12[6] = 89 // Adding a new value to the array

then do console.log 

## If you want to change on arrays any position- 

marks_class_12[0] = 96 // Changing the value of an array

then type code- console.log(marks_class_12)

Here Full Code -

let marks_class_12 = [91, 82, 63, 84, false, "Not Present"]

console.log(marks_class_12[0])

console.log(marks_class_12[1])

console.log(marks_class_12[2])

console.log(marks_class_12[3])

console.log(marks_class_12[4])

console.log(marks_class_12[5])

console.log(marks_class_12[6]) // Will be undefined because index 6 does not exist

console.log("The length of marks_class_12 is", marks_class_12.length)

marks_class_12[6] = 89 // Adding a new value to the array

marks_class_12[0] = 96 // Changing the value of an array

console.log(marks_class_12)

Now 2 topics are very important - 1. typeof

                                                      2. .length


 typeof means - how are arrays??- object or string or boolean

                 let marks_class_12 = [91, 82, 63, 84, false, "Not Present"]

                 console.log(typeof marks_class_12)

.lenth means - how arrays length? -

                 let marks_class_12 = [91, 82, 63, 84, false, "Not Present"]

                 console.log("The length of marks_class_12 is", marks_class_12.length)


























Comments