SYNTAX BUG

# Eugen.Konkov at aldec.com (18 years ago)

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' ); }

# 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 /(?:)/.