Skip to content

util.isDeepStrictEqual regex comparison #28766

Description

@Xotic750
  • Version:
    v10.14.1
  • Platform:
    Mac OS Darwin Kernel Version 18.6.0
  • Subsystem:
const util = require('util');

const rx = /a/;
rx.lastIndex = 3;

util.isDeepStrictEqual(rx, /a/); // true

util.inspect(rx, {showHidden: true}); // '{ /a/ [lastIndex]: 3 }'
util.inspect(/a/, {showHidden: true}); // '{ /a/ [lastIndex]: 0 }'

My expectation would have been false. I see that areSimilarRegExps does not perform a check on lastIndex, and keyCheck performs a comparison of enumerable keys, and lastIndex is not enumerable. This may be considered correct, but it feels wrong to me.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex

Thankyou for your time and consideration.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions