Javascript nilly nilly

Abstraction "can" be great, so use Ramda, Lodash or whatever flavor you prefer if that is what you need.

(Did you know that you can load only the functions you need from Ramda, Lodash and others?)

On the flip side, when I don't need parts of a giant utility library, and care about the implementation of my isNil function, I like to use these.

isNil
/**
 * Fast and safe utility function to test if something is `undefined, `null` or `NaN`.
 *
 * @param {*} value
 * @returns {boolean}
 */
function isNil(value) {  
    return typeof value === 'undefined' || value === null || Number.isNaN(v)
}
isNotNill
/**
 * The logical inverse of `isNil`, checks if something is NOT `undefined`, `null` or `NaN`.
 *
 * @param {*} value
 * @returns {boolean}
 */

function isNotNil(value) {  
    return isNil(value) === false
}
has
/**
 * Check if the object is defined and has the specified property as its own property
 * (as opposed to inheriting it), regardless of the value (e.x. property may exist but be null).
 *
 * @param {string} property
 * @param {object} object
 * @returns {boolean}
 */
function has(property, object) {  
    return isNotNil(object) && object.hasOwnProperty(property)
}
prop
/**
 * Check if an object is defined, and owns a property that is not `undefined, `null` or `NaN`.
 *
 * @param {string} property
 * @param {object} object
 * @returns {(*|undefined)}
 */
function prop(property, object) {  
    if (has(property, object) && isNotNil(object[property])) {
        return object[property]
    }

    return undefined
}
toArray
/**
 * Ensure the value ends up as an array, if it is not already.
 *
 * @param {*} value
 * @returns {array}
 */
function toArray(value) {  
    // if the value is already an array don't do anything
    if (Array.isArray(value)) {
        return value
    }

    // if the value is `undefined`, `null` or `NaN` return an empty array
    if (isNil(value)) {
        return []
    }

    // if the value is some other type return it as an array item
    return [value]
}

References: