Helper functions in JavaScript / JS – use lodash

For instance in my JS Applications I do often need some helper functions, like I know them from Java, like #equals etc..

lodash provide an elegant suite of helper tools.
For instance in my React App, I do

import _ from "lodash";

And I can use their functions, like in this example:

if (_.isEmpty(this.myFooAttribute)) {...

Of course you need lodash as a dependency.
In your package.json do:

 "dependencies": {
     ...
    //version is an example. I always try to use the latest.
    "lodash": "^4.17.15", 

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.