Categories
JavaScript Answers

How to do fuzzy search with JavaScript?

Spread the love

Sometimes, we want to do fuzzy search with JavaScript.

In this article, we’ll look at how to do fuzzy search with JavaScript.

How to do fuzzy search with JavaScript?

To do fuzzy search with JavaScript, we use the fuzzaldrin library.

To install it, we run

npm install fuzzaldrin

Then we use it by writing

const fuzzaldrin = require("fuzzaldrin");
const matches = fuzzaldrin.filter(["international", "splint", "tinder"], "int");

to call fuzzaldrin.filter with an array of possible matches and the search string we’re searching with.

Then filter returns an array of fuzzy search matches for searching for matches for 'int' in ["international", "splint", "tinder"].

Conclusion

To do fuzzy search with JavaScript, we use the fuzzaldrin library.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *