JavaScript / Object / String.length / 문자열의 길이 반환하는 속성
.length
.length는 문자열의 길이를 반환하는 속성입니다.
문법
string.length
예를 들어
'abcd'.length
는 4입니다.
예제
<!doctype html> <html lang="ko"> <head> <meta charset="utf-8"> <title>JavaScript</title> <style> body { font-family: Consolas, monospace; } </style> </head> <body> <script> document.write( '<p>"1234".length : ' + '1234'.length + '</p>' ); document.write( '<p>"".length : ' + ''.length + '</p>' ); document.write( '<p>"한글".length : ' + '한글'.length + '</p>' ); </script> </body> </html>