Can i write this condition in shorter version? I want to get last index of array arrarr and if the array is emty, I want to get 00(so basically add -1-1 to arr.lengtharr.length if arr.lengtharr.length is not 00)
const index = !!arr.length ? arr.length - 1 : 0;
const index = !!arr.length ? arr.length - 1 : 0;
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community
R
Reactiflux
The largest chat community for React professionals