Skip to content
Are these two JavaScript values equal?
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
.eslintrc Use babel-eslint Dec 2, 2018
.gitignore Update build to Babel 7 and Rollup Dec 1, 2018
.travis.yml Update Travis config [skip ci] Dec 2, 2018
LICENSE Add license file Dec 1, 2018
package.json Version 1.0.1 Dec 3, 2018
rollup.config.js Remove external Rollup config Dec 2, 2018

value-equal Travis npm package

value-equal determines if two JavaScript values are equal using Object.prototype.valueOf.

In many instances when I'm checking for object equality, what I really want to know is if their values are equal. This is good for:

  • Stuff you keep in localStorage
  • window.history.state values
  • Query strings


Using npm:

$ npm install --save value-equal

Then with a module bundler like webpack, use as you would anything else:

// using ES6 modules
import valueEqual from 'value-equal';

// using CommonJS modules
var valueEqual = require('value-equal');

The UMD build is also available on unpkg:

<script src=""></script>

You can find the library on window.valueEqual.


valueEqual(1, 1); // true
valueEqual('asdf', 'asdf'); // true
valueEqual('asdf', new String('asdf')); // true
valueEqual(true, true); // true
valueEqual(true, false); // false
valueEqual({ a: 'a' }, { a: 'a' }); // true
valueEqual({ a: 'a' }, { a: 'b' }); // false
valueEqual([1, 2, 3], [1, 2, 3]); // true
valueEqual([1, 2, 3], [2, 3, 4]); // false

That's it. Enjoy!

You can’t perform that action at this time.