JavaScript String Properties

Index
About This Index
This page is the JavaScript String Properties index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.
Learn what a String is on /js/string. Use this page for length and constructor. Functions such as slice() live on the String Methods index.
Read, do not call.
"Hello".length is a number. "Hello".length() throws, because length is not a function.
Syntax
How to Read a String Property
Properties are values on the string. No parentheses:
JavaScript
const title = "JavaScript";
title.length; // 10
"".length; // 0
"😀".length; // 2 (UTF-16 code units)
title.constructor; // String
typeof title; // "string" Browse
JavaScript String Properties Table
Property guides in this JavaScript tutorial series (2 tutorials).
Instance properties
2 propertiesRead these on a string value. They are data, so you do not call them with parentheses.
| Property | Description | Tutorial |
|---|---|---|
length | Read-only count of UTF-16 code units. An emoji such as 😀 can count as 2. | Open |
constructor | The function that created the string. For a string primitive it is String. Call String(value) to convert; avoid new String(). | Open |
Frequently Asked Questions
In this tutorial series the String property guides are length and constructor. length is the read-only UTF-16 code-unit count on a string. constructor is the function that created it, which is String for a string primitive.
The String page teaches what a String is—quotes, template literals, and immutability. This Properties index lists the property tutorials. Methods such as slice() and trim() are on the String Methods index.
You read a property with no parentheses: "Hello".length. You call a method: "Hello".slice(0, 2). Methods are functions; length is a number.
length counts UTF-16 code units. "Hi".length is 2. Many emoji use two code units, so "😀".length is also 2 even though you see one character.
If you are new, read JavaScript String first. Then open length. Use the Methods index when you need slice(), includes(), or trim().
Start with length
Open the property guide—syntax, emoji pitfalls, and FAQs.
8 people found this page helpful
