Certain str
functions, such as .split()
and .find()
work on patterns that
accept both string literals as well as characters. When using such functions,
prefer char
s over single-character string literals as they are more
performant.
Replace the single-character string literal with a char
.
let x = "hello, world";
x.find("o"); // single-character str
let x = "hello, world";
x.find('o'); // use a char instead