Multiple choice technology architecture

Output of the below Regular Expression function in JavaScript Var patt1 = new RegExp(“Best”); document.write(patt1.test(“The Best things in life are free”));

  1. Best.

  2. True.

  3. The Best things in life are free.

  4. Best things in life are free.

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

The test() method returns a boolean indicating whether the pattern matches the string. Here, 'Best' exists in 'The Best things in life are free', so it returns true. The method doesn't return the matched string (A), the full input string (C), or a partial match (D) - it only returns true or false.