eq.js 811 Bytes
Newer Older
徐立's avatar
徐立 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
/**
 * Performs a
 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
 * comparison between two values to determine if they are equivalent.
 * 比较两个值以确定它们是否相等。
 * @since 4.0.0
 * @category Lang 语言
 * @param {*} value 要比较的值。
 * @param {*} other 要比较的另一个值。
 * @returns {boolean} 如果值相等,则返回' true ',否则返回' false '。
 * @example
 *
 * const object = { 'a': 1 }
 * const other = { 'a': 1 }
 *
 * eq(object, object)
 * // => true
 *
 * eq(object, other)
 * // => false
 *
 * eq('a', 'a')
 * // => true
 *
 * eq('a', Object('a'))
 * // => false
 *
 * eq(NaN, NaN)
 * // => true
 */
function eq(value, other) {
32
	return value === other || (value !== value && other !== other);
徐立's avatar
徐立 committed
33 34
}

35
export default eq;