str.length
19th January 2021
0 Comments
Programming Language
JavaScript [Version: ECMAScript (ECMA-262)]
Syntax
Typical Usage
Gets the length of a string in JavaScript.
Return Value(s)
Returns the string length as an integer.Notes
You cannot assign values to string.length. For example, string.length = 9 has no effect.
Examples of str.length
Example 1
var string = 'Codeblock';
console.log(string.length);
The above will log 9 to the console, which is the length of the word ‘Codeblock’.
Similar Functions in Other Languages
- PHP: strlen()
Source
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lengthWas This Helpful?
If this post has helped you, please let me know. Your feedback will be highly appreciated and will help me build better content.