fixes and improvements to [].join()#1453
Closed
alexlamsl wants to merge 1 commit intomishoo:masterfrom
Closed
Conversation
Collaborator
Author
|
There seems to be a previous effort in #301, looking if I have missed anything and merging their test cases... |
Collaborator
Author
|
One extra bug fix:
Also improved string-type checking to output more optimal code, e.g. |
kzc
reviewed
Jan 31, 2017
| }; | ||
| input: { | ||
| var a = [ null ].join(); | ||
| var b = [ , ].join(); |
Contributor
There was a problem hiding this comment.
Can you please add another case with an array hole? [ ,1,,3 ].join()
Contributor
|
LGTM |
fixes
- [a].join() => "" + a
- ["a", , "b"].join() => "a,,b"
- ["a", null, "b"].join() => "a,,b"
- ["a", undefined, "b"].join() => "a,,b"
improvements
- ["a", "b"].join(null) => "anullb"
- ["a", "b"].join(undefined) => "a,b"
- [a + "b", c].join("") => a + "b" + c
Collaborator
Author
|
@kzc thanks! Squashed and ready to go. |
Contributor
|
This was a longstanding bug in How did you come across this issue, I'm curious? |
Collaborator
Author
|
I was combing through Then the rest is history. |
alexlamsl
added a commit
to alexlamsl/UglifyJS
that referenced
this pull request
Feb 18, 2017
fixes
- [a].join() => "" + a
- ["a", , "b"].join() => "a,,b"
- ["a", null, "b"].join() => "a,,b"
- ["a", undefined, "b"].join() => "a,,b"
improvements
- ["a", "b"].join(null) => "anullb"
- ["a", "b"].join(undefined) => "a,b"
- [a + "b", c].join("") => a + "b" + c
closes mishoo#1453
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug fixes
["a", , "b"].join()➡️"a,,b"(was"a,undefined,b")["a", null, "b"].join()➡️"a,,b"(was"a,null,b")["a", undefined, "b"].join()➡️"a,,b"(was"a,undefined,b")New optimisations
["a", "b"].join(null)➡️"anullb"["a", "b"].join(undefined)➡️"a,b"