js
JS - String 객체
String 객체는 문자열을 할당할 뿐 아니라 숫자를 문자열로 형변환을 합니다.
// 객체를 이용해 문자열을 할당
var obj_str = new String("1234");
// 변수에 문자열을 할당
var str = "1234";
<script>
document.write( new String("1234") + "<br/>"); // 1234
document.write( new String("1234.1234") + "<br/>"); // 1234.1234
// 숫자를 문자열로 형변환
document.write( new String(1234) + "<br/>"); // 1234
document.write( new String("문자열") + "<br/>"); // 문자열
</script>
0 댓글