Typically, JavaScript strings are primitive values that are generated from literals.
let x = “John”; |
However, strings can also be created as objects using the new
keyword.
let y = new String(“John”); |
let x = “John”; let y = new String(“John”); |
Avoid creating String objects. Using the |
When using the == operator, x and y are considered equal.
let x = “John”; let y = new String(“John”); |
When using the === operator, x and y are not considered equal.
let x = “John”; let y = new String(“John”); |
Be aware of the distinction between (x == y) and (x === y). |
Is (x == y) true or false?
let x = new String(“John”); let y = new String(“John”); |
Is (x === y) true or false?
let x = new String(“John”); let y = new String(“John”); |