_.has(object, path)
Checks if path
is a direct property of object
.
Since
0.1.0
Arguments
-
object
(Object): The object to query. -
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 |
Please login to continue.