O'Reilly logo
  • Brian Crebs thinks this is interesting:

Testing for Matches

Regular expression objects have a number of methods. The simplest one is test. If you pass it a string, it will return a Boolean telling you whether the string contains a match of the pattern in the expression.

console.log(/abc/.test("abcde")); //
// → true
console.log(/abc/.test("abxde"));
// → false

A regular expression consisting of only nonspecial characters simply represents that sequence of characters. If abc occurs anywhere in the string we are testing against (

From

Cover of Eloquent JavaScript, 3rd Edition

Note

Best note ever!