Lodash
v4.18.1Utility functions for arrays, objects, strings and functional programming.
Quick start
Add this tag to your page. Place it just before the closing </body> tag, or in the <head> with the defer attribute.
HTML
<script src="https://jscdns.net/libs/lodash/4.18.1/lodash.min.js"
integrity="sha384-jC7q3III065vSuJ5pJ5KABQTNoQYM3PkN9JDtaoCro/okpUkD6IKqkYr3D8hXxBp" crossorigin="anonymous"></script>Files
| File | Size | Copy |
|---|---|---|
| lodash.min.jsScript | 71.5 KB | |
| core.min.jsScript | 13.1 KB |
Usage
Complete example
A minimal page that loads Lodash and uses it. Copy it into a file and open it in your browser.
example.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<input id="search" placeholder="Type to search">
<script src="https://jscdns.net/libs/lodash/4.18.1/lodash.min.js"
integrity="sha384-jC7q3III065vSuJ5pJ5KABQTNoQYM3PkN9JDtaoCro/okpUkD6IKqkYr3D8hXxBp" crossorigin="anonymous"></script>
<script>
const onSearch = _.debounce(function (event) {
console.log('Searching for', event.target.value);
}, 300);
document.querySelector('#search').addEventListener('input', onSearch);
console.log(_.chunk(['a', 'b', 'c', 'd'], 2)); // [['a','b'], ['c','d']]
</script>
</body>
</html>Good to know. core.min.js is a much smaller build containing the most commonly used functions. Use lodash.min.js if you need the full set.