Manipulating Strings
The String
object is by far the most commonly used object in JavaScript. JavaScript automatically creates a String
object for you any time you define a variable that has a string data type. For example:
var myStr = "Teach Yourself jQuery & JavaScript in 24 Hours";
When you create a string, there are a few special characters that you can’t add directly to the string. For those characters, JavaScript provides a set of escape codes, listed in Table 2.5.
To determine the length of a string, you can use the length
property of the String
object, as in this example: ...
Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.