var x = “This is how you output a backslash (\\) in your string”;

String methods

Strings are really useful data types. Once we assign a string variable, we are able to manipulate and use that variable in a number of extremely useful ways. String methods are built-in ‘helpers’ that carry out operations on your string. We are also given many properties on our string. A property is a value, or piece of data that gets created and assigned to our string every time we create one. Let’s look at a few of the most useful methods and properties of the string data type now.

string.length

One of the most useful properties that gets assigned to our strings when we create them is the.length property. Before we discuss it in more detail, let’s first see how we use it: