@abou.bakar/has-item 中文文档教程

发布于 4年前 浏览 23 项目主页 更新于 3年前

Array Has Item

构建状态

has-item 是一个方便的轻量级库,可帮助确定特定项目/对象是否存在于 Javascript 数组中。

Install

  • npm install @abou.bakar/has-item
  • yarn add @abou.bakar/has-item

Usage

HasItem(Array, value, key)
Check Given Value Exist Or Not.
import HasItem from "@abou.bakar/has-item";

const array=[
        {id:1, name:"John"},
        {id:2, name:"Doe"},
        {id:3, name:"David"},
        {id:4, name:"Orbiqon"},
    ];
const object1={id:4, name:"Orbiqon"};
const object2={id:1, name:"Orbiqon"};
HasItem(array,object1)  // returns true
HasItem(array,object2)  // returns false
Check Specific value inside object.
import HasItem from "@abou.bakar/has-item";

const array=[
        {id:1, name:"John"},
        {id:2, name:"Doe"},
        {id:3, name:"David"},
        {id:4, name:"Orbiqon"},
    ];

HasItem(array,"John","name")  // returns true
HasItem(array,5,"id")  // returns false
ParameterDescriptionRequired
First parameterFirst parameter is an arrayRequired
Second parameterSecond parameter is the value which will check in arrayRequired
Third parameterThird parameter is the key of a specific object element of array which will check in arrayOptional

Array Has Item

Build Status

has-item is a handy, lightweight library which helps to find out if a particular item/object exists in a Javascript array or not.

Install

  • npm install @abou.bakar/has-item
  • yarn add @abou.bakar/has-item

Usage

HasItem(Array, value, key)
Check Given Value Exist Or Not.
import HasItem from "@abou.bakar/has-item";

const array=[
        {id:1, name:"John"},
        {id:2, name:"Doe"},
        {id:3, name:"David"},
        {id:4, name:"Orbiqon"},
    ];
const object1={id:4, name:"Orbiqon"};
const object2={id:1, name:"Orbiqon"};
HasItem(array,object1)  // returns true
HasItem(array,object2)  // returns false
Check Specific value inside object.
import HasItem from "@abou.bakar/has-item";

const array=[
        {id:1, name:"John"},
        {id:2, name:"Doe"},
        {id:3, name:"David"},
        {id:4, name:"Orbiqon"},
    ];

HasItem(array,"John","name")  // returns true
HasItem(array,5,"id")  // returns false
ParameterDescriptionRequired
First parameterFirst parameter is an arrayRequired
Second parameterSecond parameter is the value which will check in arrayRequired
Third parameterThird parameter is the key of a specific object element of array which will check in arrayOptional
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文