let variable = [n, "value", value]
=> Declare an array and can Initialize it with any type of valuelet variable = new Array(value1, value2)
let variable = new Array(n)
=> Creates an array of n undefined elementsvariable[N]
=> Access value in arrayvariable.length
=> Returns length of arrayvariable.toString()
=> Returns a string made by elements of array separated by commavariable.isArray()
=> Returns boolean value if it is array or notvariable.join("value")
=> Returns a string made by joining all elements using given separatorvariable.concat(variable1, variable2)
=> Concatenate the array passed to concat to the end of the arrayvariable.concat(variable1)
variable.indexOf(value)
=> Returns index of the valuevariable.includes(value)
Returns boolean value if element is present or notvariable.sort()
=> By default converts values into string and then sort according to dictionaryvariable.sort(compare)
=> Compare should be a functionvariable.slice(N1, N2)
=> Returns an array starting from index N1 to index of N2, but not including the last indexdelete variable[N]
=> Deletes the element of the given index, Value becomes undefined, Length does not changevariable.push(val)
=> Adds element at the end of the array, Returns length of arrayvariable.push(val1, val2)
=> Add more than 1 elementvariable.pop()
=> Removes and Returns the last value from the arrayvariable.shift()
=> Removes and Returns first element from the arrayvariable.unshift(value)
=> Appends in the front and Returns length of arrayvariable.reverse()
=> Reverse the order of the elements in an arrayvariable.splice(N1, N2, value1, value2)
=> N1 is position to add, N2 is number of elements to remove, Then elements to be added, Returns array of deleted values variable.forEach((value, index, array) => {
// Statements
})
variable.from(var).forEach((element) => {
// Statements
})
variable.find((value, index) => {
return condition;
})
variable.findIndex((value) => {
return condition;
})
variable.map((value, index, array) => (
<div></div>
))
variable.map((value, index, array) => {
// Statements
return (
<div></div>
)
})
variable.filter((value) => {
return condition;
})
variable.reduce((value1, value2) => {
return condition;
})
for(variable1 in variable) {
// Statements
}
for(variable1 of variable) {
// Statements
}
variable.some(checkAdult);
function checkAdult(age) {
return age > 18;
}
variable.every(checkAdult);
function checkAdult(age) {
return age > 18;
}
--
[variable1, variable2] = [value1, value2]
=> value1 & value2 will be assigned to variable1 & variable2 respectively[variable1, variable2] = [value1, value2, value3, value4]
=> value1 & value2 will be assigned to variable1 & variable2 respectively[variable1, , , variable4] = [value1, value2, value3, value4]
=> value1 & value4 will be assigned to variable1 & variable4[variable1, variable2, variable3, ...variable4] = [value1, value2, value3, value4, value5, value6]
=> value1 & value2 & value3 will be assigned to variable1 & variable2 & variable3 respectively, Rest all to variable4 as array {variable1, variable2, variable3, …variable4} = [
variable1: value1,
variable2: value2,
variable3: value3,
variable4: value4,
variable5: value5
]
variable = { ...[value1, value2, value3] }
=> Creates key-value pair and stores in variableconsole.log({ ...variable, key: "value" })
=> Only the given pair changes