Javascript  

 

 

 

 

 

Array

 

This note is not much of programming... it would be just about basic syntax. The syntax about handling Array in Javascript.

 

  • push() and pop(): These methods add and remove elements from the end of an array, respectively.
  • shift() and unshift(): These methods add and remove elements from the beginning of an array, respectively.
  • splice(): This method can be used to add or remove elements from anywhere in an array.
  • slice(): This method returns a new array that contains a subset of the elements of the original array.
  • concat(): This method can be used to combine two or more arrays into a single array.
  • indexOf(): This method returns the index of the first occurrence of a specified element in an array, or -1 if the element is not present.
  • join(): This method can be used to join all elements of an array into a single string.
  • sort(): This method can be used to sort the elements of an array in ascending or descending order.
  • reverse(): This method can be used to reverse the order of the elements in an array.
  • map(): this method is used to create a new array with the same length as the original array, but with the elements transformed according to the provided function.
  • Apply Function : Apply a function (e.g, a Math function) to every element of an array
  • Spread Opeartor : Spread an array to a sequence of individual elements

 

 

 

push / pop

 

 

 

 

 

 

shift/unshift

 

 

 

 

 

 

slice

 

 

 

 

splice

 

 

 

 

 

 

 

indexOf

 

 

 

 

concat

 

 

 

 

join

 

 

 

 

 

sort

 

 

 

 

 

 

 

map

 

 

 

 

 

Apply Function

 

 

 

 

Spread Operator

 

 

 

 

 

Object Array

 

An object array is an array that contains elements that are objects. Each element in the array is an object, and each object has its own properties and methods.

 

An object can be defined as an instance which contains set of key-value pairs and it can be defined using the object literal notation {} or the object constructor notation (new Object()).