Posts

JavaScript pop() Method

  Definition and Usage The  pop()  method removes (pops)  the last element  of an array. The  pop()  method changes the original array. The  pop()  method returns the removed element. <! DOCTYPE html > < html lang = "en" > < head >   < meta charset = "UTF-8" >   < meta http-equiv = "X-UA-Compatible" content = "IE=edge" >   < meta name = "viewport" content = "width=device-width, initial-scale=1.0" >   < title >Document</ title > </ head > < body >   < h1 >JavaScript Array pop() Method</ h1 >   < script >     const myNumbers = [ 1 , 4 , 8 , 4 ];         console . log (myNumbers);     console . log (myNumbers . pop ());     console . log (myNumbers);           </ script > </ body > </ html >

JavaScript unshift() Method

  Definition and Usage The  unshift()  method adds new elements to  the beginning  of an array. The  unshift()  method overwrites the original array. Return Value Type Description A number The new length of the array. syntex array .unshift( item1 ,  item2 , ...,  itemX ) <! DOCTYPE html > < html lang = "en" > < head >   < meta charset = "UTF-8" >   < meta http-equiv = "X-UA-Compatible" content = "IE=edge" >   < meta name = "viewport" content = "width=device-width, initial-scale=1.0" >   < title >Document</ title > </ head > < body >   < h1 >JavaScript Array unshift() Method</ h1 >   < script >     const fruits = [1, 4, 8, 4];     console . log (fruits . unshift ( 2 ));     console . log (fruits);   </ script > </ body > </ html >

JavaScript Array push() Method

 JavaScript Array push() Method -------------------------------------------------- Definition and Usage The  push()  method adds new items  to the end  of an array. The  push()  method changes the length of the array. The  push()  method returns the new length Syntax  array .push( item1 ,  item2 , ...,  itemX ) <! DOCTYPE html > < html lang = "en" > < head >   < meta charset = "UTF-8" >   < meta http-equiv = "X-UA-Compatible" content = "IE=edge" >   < meta name = "viewport" content = "width=device-width, initial-scale=1.0" >   < title >Document</ title > </ head > < body >   < h1 >JavaScript Array push() Method</ h1 >   < script >     const fruits = [ "Banana" , "Orange" , "Apple" , "Mango" ];         // console.log(fruits.push("Pine Apple"));     // console.log(fruits); ...

JavaScript Array sort() Method

  Definition and Usage The  sort()  sorts the elements of an array. The  sort()  overwrites the original array. The  sort()  sorts the elements as strings in alphabetical and ascending order. For Number  Sort Compare Function Sorting alphabetically works well for strings ("Apple" comes before "Banana"). But, sorting numbers can produce incorrect results. "25" is bigger than "100", because "2" is bigger than "1". You can fix this by providing a "compare function" (See examples below) <! DOCTYPE html > < html lang = "en" > < head >   < meta charset = "UTF-8" >   < meta http-equiv = "X-UA-Compatible" content = "IE=edge" >   < meta name = "viewport" content = "width=device-width, initial-scale=1.0" >   < title >Document</ title > </ head > < body >   < script >     const fruits = [ "...

JavaScript Array filter()

  Definition and Usage The  filter()  method creates a new array filled with elements that pass a test provided by a function. The  filter()  method does not execute the function for empty elements. The  filter()  method does not change the original array. syntex array .filter( function(currentValue, index, arr), thisValue ) thisValue =>   Optional. Default  undefined A value passed to the function as its  this  value. <! DOCTYPE html > < html lang = "en" > < head >   < meta charset = "UTF-8" >   < meta http-equiv = "X-UA-Compatible" content = "IE=edge" >   < meta name = "viewport" content = "width=device-width, initial-scale=1.0" >   < title >Document</ title > </ head > < body >   < h1 >JavaScript Array filter() Method</ h1 >   < script >     const ages = [ 20 , 56 , 23 , 30 , 18 , 20 , 70 , 40 , 45 , 1...

JavaScript Find and FindIndex Method

    Want to understand Properly Plz see the video carefully on YouTube channel name is Adisma ------------------------------------------------------------------------ Definition and Usage The  find()  method returns the value of the first element that passes a test. The  find()  method executes a function for each array element. The  find()  method returns  undefined  if no elements are found. The  find()  method does not execute the function for empty elements. The  find()  method does not change the original array. ------------------------------------------------------------ The  findIndex()  method executes a function for each array element. The  findIndex()  method returns the index (position) of the first element that passes a test. The  findIndex()  method returns -1 if no match is found. The  findIndex()  method does not execute the function for empty array elements...

JavaScript includes() Method or Function

    Want to understand Properly Plz see the video carefully on YouTube channel name is Adisma ------------------------------------------------------------------------ The  includes()  method returns  true  if a string contains a specified string. Otherwise it returns  false . The  includes()  method is case sensitive. <! DOCTYPE html > < html lang = "en" > < head >   < meta charset = "UTF-8" >   < meta http-equiv = "X-UA-Compatible" content = "IE=edge" >   < meta name = "viewport" content = "width=device-width, initial-scale=1.0" >   < title >Document</ title > </ head > < body >   < h1 >includes() Method</ h1 >   < script >     const myList = [ 1 , 2 , 3 , 5 , "seemaSharma" , "adisma" , "seema" ];     console . log (myList . includes ( "seema" ));   </ script > </ body > </ html ...