when var patt is cretaed as shown above, how does it create an object of RegExp type ? To create an object of a particular type, its required to be created as "var patt=new RegExp(pattern,modifiers);" If we just specify "var patt=/Hello/g;" how will script understand that its of RegExp type only and nothing else ?
var str="Hello world!";
//look for "Hello"
document.write("Returned value: " + result);
It is the literal syntax of the regex object, just as we have string literal, number literal, object literal and such.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)