How to check whether the value exists in array ?

Asked on May 28, 2018

I want to search particular value in array. For example I have array of users , I want to check particular user is present in that array. 
     My array is as follows:

  1. Array(5)
    1. length:5

Replied on May 29, 2018
Use find(), for example

let data = arrays.find(ob => ob['name'] === 'admin');

if data is null then no admin.

Replied on May 29, 2018
Thank you.

Write Answer

©2024 | Privacy Policy | Contact Us