last index array javascript
var colors = ["red","blue","green"];
var green = colors[colors.length - 1]; //get last item in the array
const array = ['a', 's', 'd', 'f'];
const last = array.pop();
console.log(last); // Returns 'f'
console.log(array); // Returns ['a', 's', 'd']
Also in JavaScript:
- random number js
- how to display first value of an array in jquery
- does a function inside a function need to be called?
- weakset in es6
- js remove value input
- webpack react proxy not working
- javascript negative infinity
- jquery add attribute
- remove element from array in js
- javascript loop through array of objects es6
- JSONDecoder
- select first option in dropdown jquery
- js find place value
- return uncommon from two arrays js
- facebook pixel
- cypress memory leak
- type of javascript
- starting with react router dom
- laravel json eloquent
- function if else javascript
- javascript stop execution
- javascript time execution
- javascript search like
- javascript write to text file