John G Harris wrote:
Quote:
It didn't "keep its special value". \0 is not the null character in
ECMAScript version 2, but it is in version 3.
15.10.2.11 DecimalEscape is the only place vaguely mentioning \0 and
NUL but right - I was deeply wrong.
Quote:
It looks as though \0 was added in version 3 because so many people like
VK wanted it.
I wanted NUL for a language where strings are not null-terminated? No,
no, no! :-)
I played a bit with that freshly discovered (for me) NUL. While string
methods acting as they possibly(?) should if strings are not
null-terminated, overall the engine seems pretty much FOBAR (in the US
Army sense of this acronym):
<script language=javascript>
x='123'+'\0'+'456';
alert(x); // 123
alert(x.length); // 7
alert(x.charAt(6)); // 6
a={};
a[x] = 1;
for (var p in a) {
alert(''+p); // 123
alert((''+p).length); // 7
alert((''+p).charAt(6)); // 6
}
alert(x == '123');
</script>