Multiple choice technology programming languages

What is the output of the below JavaScript?


var patt1 = new RegExp("e");        
alert(patt1.test("This is an example"));    

  1. false

  2. true

  3. e

  4. 11

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The RegExp pattern 'e' matches the letter 'e'. The test() method checks if this pattern exists in the string 'This is an example'. Since the string contains multiple 'e' characters, test() returns true. Option A is wrong because the test method returns a boolean, not the search result.