SYNTAX BUG
# liorean (18 years ago)
On 16/10/2007, Eugen.Konkov at aldec.com <Eugen.Konkov at aldec.com> wrote:
In the next line there is ambigious between RegEx and comment str.match(//);
Not really. // is always a line comment starter in ES3:
7.8.5 Regular Expression Literals
/- - -/
NOTE Regular expression literals may not be empty; instead of
representing an empty regular expression literal, the characters //
start a single-line comment. To specify an empty regular expression,
use /(?:)/.
In the next line there is ambigious between RegEx and comment str.match(//);
FAILS: syntax error
var str='a'; if( str.match(//) ) { alert( 'YES' ); } else { alert( 'No' ); }
OK: alerts 'YES'
var str='a'; if( str.match(/a/) ) { alert( 'YES' ); } else { alert( 'No' ); }
In the next line there is ambigious between RegEx and comment str.match(//); FAILS: syntax error -------------------------- var str='a'; if( str.match(//) ) { alert( 'YES' ); } else { alert( 'No' ); } OK: alerts 'YES' -------------------------- var str='a'; if( str.match(/a/) ) { alert( 'YES' ); } else { alert( 'No' ); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.mozilla.org/pipermail/es-discuss/attachments/20071016/412f16c4/attachment-0002.html