js take last item in array
var colors = ["red","blue","green"];
var green = colors[colors.length - 1];//get last item in the arrayconst heroes = ["Batman", "Superman", "Hulk"];
const lastHero = heroes.pop(); // Returns last elment of the Array
// lastHero = "Hulk"
Also in JavaScript:
- how javascript works
- how to get only citnames in google maps api js
- js detect device
- js array .filter
- js check if radio button is checked
- how to call javascript method using selectlist on change in vf page
- javascript convert number from thousands to k and millions to m
- electron save as dialog
- javascript merge multidimensional array
- change class javascript
- discord js clear message from id
- how to pad string js
- npm start for production
- node js serve pdf file
- discord.js bot
- js remove element from array
- javascript load content from file
- electronjs ipc doesn't work
- getBoundingClientRect
- javascript check if elements of one array are in another
- npm font awesome 5
- ES6: Set Default Parameters for Your Functions
- how to program an array in js
- jest mock call