_.has

_.has(object, path)

Checks if path is a direct property of object.

Since

0.1.0

Arguments

  1. object (Object): The object to query.
  2. path (Array|string): The path to check.

Returns

(boolean): Returns true if path exists, else false.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var object = { 'a': { 'b': 2 } };
 
var other = _.create({ 'a': _.create({ 'b': 2 }) });
  
_.has(object, 'a');
// => true
  
_.has(object, 'a.b');
// => true
  
_.has(object, ['a''b']);
// => true
  
_.has(other, 'a');
// => false
doc_Lodash
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.