Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: change abstract equal to strict equal #22974

Closed
wants to merge 2 commits into from

Conversation

ZYSzys
Copy link
Member

@ZYSzys ZYSzys commented Sep 20, 2018

Just change the rare == to ===, nothing else be affected.
Unify the style, may looks more comfortable 😄.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the console Issues and PRs related to the console subsystem. label Sep 20, 2018
@@ -349,7 +349,7 @@ Console.prototype.table = function(tabularData, properties) {
if (properties !== undefined && !ArrayIsArray(properties))
throw new ERR_INVALID_ARG_TYPE('properties', 'Array', properties);

if (tabularData == null || typeof tabularData !== 'object')
if (tabularData === null || typeof tabularData !== 'object')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not obvious, but this significantly changes the semantics of the check in a non-backwards compatible way.

null == null; // true
undefined == null; // true
null === null; // true
undefined === null; // false

The current check makes sure that tabularData is also not undefined.

Copy link
Member Author

@ZYSzys ZYSzys Sep 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the later one can check it, typeof undefined === 'undefined' so typeof tabularData !== 'object' is true.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is 100 % subjective, but maybe this would be a bit more Obviously Correct™ if the conditions were switched?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just not seeing the point of the change then if it simply shifts the undefined case a bit to the right.

Copy link
Member Author

@ZYSzys ZYSzys Sep 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just change to strict equal to unify the overall code style.
If there is any problem, feel free to close it.😜

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, I'm not overly happy with it but I won't block it :-)

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment.

@jasnell jasnell dismissed their stale review September 21, 2018 18:07

choosing not to block...

@addaleax
Copy link
Member

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Sep 24, 2018
@trivikr
Copy link
Member

trivikr commented Sep 25, 2018

@danbev
Copy link
Contributor

danbev commented Sep 27, 2018

Landed in 0f84120, and ccbedd5.

@danbev danbev closed this Sep 27, 2018
danbev pushed a commit that referenced this pull request Sep 27, 2018
PR-URL: #22974
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
danbev pushed a commit that referenced this pull request Sep 27, 2018
PR-URL: #22974
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@ZYSzys
Copy link
Member Author

ZYSzys commented Sep 27, 2018

Thanks all of you.

@ZYSzys ZYSzys deleted the strict branch September 27, 2018 03:42
targos pushed a commit that referenced this pull request Sep 27, 2018
PR-URL: #22974
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
targos pushed a commit that referenced this pull request Sep 27, 2018
PR-URL: #22974
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. console Issues and PRs related to the console subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants