String is a primitive data type representing an immutable sequence of zero or more 16-bit unsigned integer values. Each element in the string occupies a specific index and represents a UTF-16 code unit.
Instantiation and Syntax
Strings can be created as primitives using literal syntax or as objects using theString constructor.
Immutability
String primitives are strictly immutable. Once a string is created, its sequence of code units cannot be altered. Operations that appear to modify a string actually allocate a new string in memory and return the new reference.Encoding and the length Property
JavaScript strings use UTF-16 encoding. The length property returns the number of 16-bit code units, not necessarily the number of visible characters (graphemes). Characters within the Basic Multilingual Plane (BMP) require one code unit, while astral plane characters (like emojis or rare symbols) require two code units, known as a surrogate pair.
Autoboxing
When a property or method is accessed on a string primitive, JavaScript temporarily coerces the primitive into aString wrapper object, executes the method, and immediately discards the wrapper. This allows primitives to utilize the String.prototype API without the memory overhead of permanent objects.
Character Access
Individual code units can be accessed via zero-based indexing.Core String.prototype API
The prototype provides methods for inspection, extraction, and transformation. All transformation methods return a new string.
Extraction:
Tired of Poor JavaScript Skills? Fix That With Deep Grasping!Learn More





