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

To use the include function from the Underscore library in JavaScript, you first need to include the Underscore script file in your HTML document:

<script src="underscore.js"></script>
38 chars
2 lines

Then, in your JavaScript code, you can use the _.include function to check if a value is included in an array:

index.tsx
// create an array of numbers
var numbers = [1, 2, 3, 4, 5];

// check if the number 3 is included in the array
if (_.include(numbers, 3)) {
  console.log("3 is included in the array");
} else {
  console.log("3 is not included in the array");
}
246 chars
10 lines

The _.include function returns true if the value is included in the array, and false otherwise.

gistlibby LogSnag