I have a array below that is constantly changing. It is being using in a node.js app. I have everything working good that updates elements of the array but if I restart node and the browser is still running, the webpage still sends data and causes it to crash, so I need to check if array exists before it tries to do something.
My array is like this, called users :-
[ { username: 'a',
active: true,
lat: '52.4099584',
lng: '-1.5310848' } ]
So I need to check username 'a' exists. I have tried
users.map(obj => obj.username).indexOf(value) >= 0;
but doesnt work?
Any suggestions?
Thanks
users.some( obj => obj.username === 'a' )?