time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

hasIn.js (753B)


      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;