Javascript - Length
📖 Read the lesson
Code Life
By Pierre Marsaa
Introducing the .length Property
Strings in JavaScript have a special built-in property called
.length
that tells you how many characters are in the string.
To use it, you write the string (or variable containing a string) followed by a dot
.
and then
length
:
↗️
Loading editor...
↶
▶️ Run
↷
Notice that
.length
does NOT have parentheses
()
after it. That's because it's a
property
, not a method (function).
Verify