I understand that Typescript is based on ES6 or ES2015.
However, I'm confused because anArray.includes('ifExist');
is only available in ES6.
Even though I'm using Typescript, why am I unable to use it? The error message says that anArray
does not have the method includes
.
My Array
anArray = [
{
'category': 'x',
'data': []
},
{
'category': 'y',
'data': []
},
{
'category': 'z',
'data': []
}
];
ifExist variable
ifExist = {
'category': 'a',
'data': []
};
Instead of anArray.indexOf(isExist) < 0
, if I use this, I can achieve a similar result to anArray.includes(isExist)
.