how to use the include function from the underscore library in typescript

To use the include function from the Underscore library in Typescript, you first need to install Underscore and its Typescript definitions:

npm install underscore
npm install @types/underscore
53 chars
3 lines

Then, you can import the _ object from the Underscore library and use the include function in your Typescript project:

index.ts
import _ from 'underscore';

const fruits = ['apple', 'banana', 'orange'];
const hasBanana = _.includes(fruits, 'banana'); // true
131 chars
5 lines

Note that this code assumes that you have set up your Typescript project to use modules. If you're not familiar with modules in Typescript, you can check out the official documentation for more information: https://www.typescriptlang.org/docs/handbook/modules.html

gistlibby LogSnag