Last change
on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
753 bytes
|
Line | |
---|
1 | var baseHasIn = require('./_baseHasIn'),
|
---|
2 | hasPath = require('./_hasPath');
|
---|
3 |
|
---|
4 | /**
|
---|
5 | * Checks if `path` is a direct or inherited property of `object`.
|
---|
6 | *
|
---|
7 | * @static
|
---|
8 | * @memberOf _
|
---|
9 | * @since 4.0.0
|
---|
10 | * @category Object
|
---|
11 | * @param {Object} object The object to query.
|
---|
12 | * @param {Array|string} path The path to check.
|
---|
13 | * @returns {boolean} Returns `true` if `path` exists, else `false`.
|
---|
14 | * @example
|
---|
15 | *
|
---|
16 | * var object = _.create({ 'a': _.create({ 'b': 2 }) });
|
---|
17 | *
|
---|
18 | * _.hasIn(object, 'a');
|
---|
19 | * // => true
|
---|
20 | *
|
---|
21 | * _.hasIn(object, 'a.b');
|
---|
22 | * // => true
|
---|
23 | *
|
---|
24 | * _.hasIn(object, ['a', 'b']);
|
---|
25 | * // => true
|
---|
26 | *
|
---|
27 | * _.hasIn(object, 'b');
|
---|
28 | * // => false
|
---|
29 | */
|
---|
30 | function hasIn(object, path) {
|
---|
31 | return object != null && hasPath(object, path, baseHasIn);
|
---|
32 | }
|
---|
33 |
|
---|
34 | module.exports = hasIn;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.