Introduction to Loadash Js and its `identity` property (part 1)

What is Lodash

Lodash is a JavaScript library which provides utility functions for common programming tasks, delivering consistency, modularity and performance etc and it provides simple to use methods that solve common problems.

Why Lodash

  • Provides consistent cross browser support.
  • Able to use both for frontend & backend.
  • Lodash can follow DRY principle.
  • Performance and optimization for speed is better rather than native and more readable.
  • Declarative type.
  • Have good amount of contributors and active in their respositories.
  • Support every browser basically.

How

  • Can use locally or globally
  • Can also go through with npm
  • For backend use, have to require lodash in code.

I will introduce with a property called identity using in lodash js

Identity

var res = _.identity('hlaing', 'tin');
// res is hlaing

Method returns the first argument

_.identity in documentation of _.findKey and _.findLastKey

var data = {
    topic: "lodash",
    desc: "js library",
    awesome: "chaining"
};

var keyRes = _.findKey(p);        // returns "topic"
var lastKeyRes = _.findLastKey(p);    // returns "awesome"

// same with above 
var keyRes = _.findKey(p, _.identity);
var lastKeyRes = _.findLastKey(p, _.identity);

// which again means the same scenario:
var keyRes = _.findKey(p, function(x) { return x; }
var lastKeyRes = _.findLastKey(p, function(x) { return x; }

I introduced the identity property this week and will introduce the rest functionalities in coming weeks.

By Yuuma



アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム