Introduce the concept of Arrays, in terms of sting character indexes.
Terminology
String Literal
A string value created using either single or double quotes.
Coercion
Converting a value from one type to another. In this case, string primitives will be converted to an object when you try to use string.length or a string prototype method.
A collection of name/value pairs (in terms of Javascript)
Property
A fancy term for a variable that lives inside an object and is most often accessed using dot notation. Example: string.length.
Method
A fancy term for a function that lives inside an object and is most often accessed using dot notation. Example: string.trim().
String Constructor
When paired with the new keyword, a string constructor creates a fully qualified string object with all the properties and methods inherited with the prototype. It can also be called as a function to convert any type into a string primitive type.
Deep dark secret: everything in Javascript is actually an object.
Although a string is one of the primitive types, it is implicitly coerced into an object. This means that using new String() is rare since we get the methods anyway.
The String() constructor can be used in two ways!
new String('some string/value') will create a String object (you will do this rarely).
Calling it as a function: String('some value') will convert that value to a string primitive (you will do this more often).
Along with string.length string characters are also copied into an array; each character is given a number, starting at zero, in order of the characters. Each character can be accessed with bracket notation.
2. Demo: String methods and character counters
Learning Objectives
Explore some useful methods that are available for strings.
Identify whether a method is an expression or not.