I know that Typescript use ES6 or ES2015.
And I know that anArray.includes('ifExist'); only available in ES6.
But why can't I use it when I use Typescript?
It says that anArray don't have a method includes.
My Array
anArray = [
{
'category': 'x',
'data': []
},
{
'category': 'y',
'data': []
},
{
'category': 'z',
'data': []
}
];
ifExist variable
ifExist = {
'category': 'a',
'data': []
};
If I use anArray.indexOf(isExist) < 0, I can get the result like anArray.includes(isExist).
You need to specify target in your ts-config.json to ES2016 (or higher) in order to use Array.includes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With