String#split has always returned the input string if no separator is specified. This did not change in ES2018.
I think you meant:
'
'.split('');
…which returns:
['\uD83D', '\uDE80']
…but this hasn‘t changed in ES2018 either.
See https://mths.be/jsu for details.
-
-
If you really meant '
'.split() (with no separator) and that‘s giving you a multi-element array (like in your first example), that‘s a bug. Which JS engine has this behavior?1 reply 0 retweets 0 likes -
Replying to @mathias @FakeUnicode and
sorry for wasting your time, my testing was incorrect.
1 reply 0 retweets 0 likes -
Replying to @glasnt @FakeUnicode and
Ah, no worries. Thanks for double-checking!
1 reply 0 retweets 0 likes -
Here's one that might be answerable (apologies if not). My notes indicate that between Chrome 63 and Chrome 64 consoles, "{}" was no longer considered a anonymous code block, so "{} + []" and "[] + {}" were commutative. I cannot replicate this in Chrome 68. Was I dreaming?
1 reply 0 retweets 0 likes -
The original version of this code sample from the "wat" talk shows the same non-commutative behaviour in jsc. Would that be "magic" there too?
1 reply 0 retweets 0 likes -
Assuming no surrounding code, `{}` has different meanings in those two snippets. The `{}` in `[] + {}` is an ObjectLiteral. https://tc39.github.io/ecma262/#prod-ObjectLiteral … The `{}` in `{} + []` is an empty Block. https://tc39.github.io/ecma262/#prod-Block …
1 reply 0 retweets 1 like
TL;DR The different output is the correct behavior. Commutativity doesn’t really apply here as `{}` means different things. I can’t answer your question re: those old Chrome versions, though. It’s possible you spotted a bug in the DevTools console that was since fixed.
-
-
Thanks for the detailed response
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.