본문 바로가기

study

javascript 문자열 길이 length

 string.length

ex)'abc'.length

<!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>