You can call any of the methods of the String
object on a string literal value—JavaScript automatically converts the string literal to a temporary String
object, calls the method, then discards the temporary String
object. You can also use the length
property with a string literal.
Strings are immutable
- Methods in string
Text formatting - JavaScript | MDN