Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Javascript index,length,push,pop,shift,unshift

var friends = ["Abrar", "Adil", "Adnan", "Alvi", "Ashraf"];
var friendsIndex = friends.indexOf("Alvi");
//Output:3
var friendsLength = friends.length;
//Output: 5
var friendsPositonChange = friends[3] = "Arif";
//Output: [ 'Abrar', 'Adil', 'Adnan', 'Arif', 'Ashraf' ]

var friendsPush = friends.push("Tahmina")
//Output:[ 'Abrar', 'Adil', 'Adnan','Arif', 'Ashraf', 'Tahmina' ]
var friendsPop = friends.pop();
//Output: [ 'Abrar', 'Adil', 'Adnan', 'Arif', 'Ashraf' ]

var friendsShift = friends.shift();
//Output: [ 'Adil', 'Adnan', 'Arif', 'Ashraf' ]

var friendsUnshift = friends.unshift("Shafi")
//Output: [ 'Shafi', 'Adil', 'Adnan', 'Arif', 'Ashraf' ]
console.log(friends)
Comment

PREVIOUS NEXT
Code Example
Javascript :: Get the text inside a paragraph 
Javascript :: Remove a class when the backspace-key is pressed inside the input field 
Javascript :: function reducer sintaxe 
Javascript :: React Rendering Movies 
Javascript :: jquery autocomplete set suggestion length 
Javascript :: how to prevent random method from giving more than two same numbers js site:stackoverflow.com 
Javascript :: How to Subtract the numbers in the array, starting from the left in javascript 
Javascript :: Fibonacci perticular position in javascript 
Javascript :: for const 
Javascript :: reversing string 
Javascript :: add content in textarea by clicking on button 
Javascript :: import lodash react 
Javascript :: Kontol Javascript 
Javascript :: option 1 
Javascript :: tictactoe - javascript 
Javascript :: jquery get selected checkbox items and pass to parameter for C# MVC consumption 
Javascript :: how to set the id attr to a var in reactjs 
Javascript :: tab pane full calendar not showing 
Javascript :: nodejs spawn detached command 
Javascript :: node.js sign in to website and get contents of new page 
Javascript :: multi-line string shorthand javascript 
Javascript :: javascript random number between 10 and 100 
Javascript :: errorhandler npm 
Javascript :: take money from user and give change as output using javascript 
Javascript :: downlaod file from website raect 
Javascript :: hook redux state with redux extension 
Javascript :: email validation in form using javascript 
Javascript :: Public properties can be created via Instance public fields 
Javascript :: joi for validation 
Javascript :: on number copy pase formate in reactjs 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =