0
rated 0 times
[
7]
[
7]
/ answers: 1 / hits: 86459
/ 8 Years ago, fri, january 6, 2017, 12:00:00
I want to check if a data.objectId
already exists in the array msgArr
. For that I am running the code below:
var exists = msgArr.objectId.includes(data.objectId);
if(exists === false){
msgArr.push({objectId:data.objectId,latLont:data.latLont,isOnline:data.isOnline});
}
The array looks like the following:
var msgArr = [
{isOnline:true,latLont:123,objectId:on0V04v0Y9},
{isOnline:true,latLont:1,objectId:FpWBmpo0RY},
{isOnline:true,latLont:48343,objectId:Qt6CRXQuqE}
]
I am getting the error below:
Cannot read property 'includes' of undefined
More From » typescript