Posts

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 ...

JavaScript lastIndexOf() method

  Want to understand Properly Plz see the video carefully on YouTube channel name is Adisma Definition and Usage The  lastIndexOf()  method returns the index (position) of the last occurrence of a specified value in a string. The  lastIndexOf()  method searches the string from the end to the beginning. The  lastIndexOf()  method returns -1 if the value is not found. The  lastIndexOf()  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 >Searching In An Array = lastIndexOf () Method</ h1 >   < script >     const myFriends = [ "seema" , "Seema Sharma" , "Adisma" , ...

JavaScript indexOf() Method

    Want to understand Properly Plz see the video carefully on YouTube channel name is Adisma The  indexOf()  method returns the position of the first occurrence of a value in a string. The  indexOf()  method returns -1 if the value is not found. The  indexOf()  method is case sensitive. <! DOCTYPE html > < html lang = "en" > < head >   < meta charset = "UTF-8" >a   < 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 >Searching In An Array = indexOf() Method</ h1 >   < script >       const myFriends = [ "seema" , "Seema Sharma" , "Adisma" , "seema" , "Aditya" ];       console . log ( "Index Number =" + myFriends . indexOf ( "Adisma...