string search library in js code example

Example 1: js string search

var str = "This is a test sentence";
var hasTest = str.includes("test");

if(hasTest == true){
	//do a thing 
}

Example 2: fuzzy search javascript

// This can be excluded when loaded via <script>import FuzzySearch from 'fuzzy-search'; // Or: var FuzzySearch = require('fuzzy-search'); const people = [{  name: {    firstName: 'Jesse',    lastName: 'Bowen',  },  state: 'Seattle',}]; const searcher = new FuzzySearch(people, ['name.firstName', 'state'], {  caseSensitive: true,});const result = searcher.search('ess');

Example 3: javascript fuzzy search

const options = {
  includeScore: true,
  // Search in `author` and in `tags` array
  keys: ['author', 'tags']
}

const fuse = new Fuse(list, options)

const result = fuse.search('tion')