JavaScript

[Conversion] JS - "" 타입변환 - (숫자: 0 , 문자열: "" , 참거짓: false)

"" 타입변환

 

<p id="demo"></p>


<script>

var x = "";

document.getElementById("demo").innerHTML =

"Number : " + Number(x) + "<br>" +

"String : " + String(x) + "<br>" +

"Boolean: " + Boolean(x);

</script>

 

결과보기

결과값:

Number : 0

String : 

Boolean: false

 

주의: 따옴표 사이에 공백이 한 칸 존재하면, 참거짓 값이 true 찍힘.

 

<p id="demo"></p>


<script>

var x = " ";

document.getElementById("demo").innerHTML =

"Number : " + Number(x) + "<br>" +

"String : " + String(x) + "<br>" +

"Boolean: " + Boolean(x);

</script>

 

결과보기

결과값:

Number : 0

String : 

Boolean: true

 


분류 제목
DOM_Attribute JS - nodemap.item() 메서드 -
DOM_Attribute JS - nodemap.length -
DOM_Attribute JS - nodemap.removeNamedItem() 메서드 -
DOM_Attribute JS - nodemap.setNamedItem() 메서드 -
DOM_Attribute JS - attr.appendChild() 메서드 - 사용금지
DOM_Attribute JS - attr.attributes - 사용금지
DOM_Attribute JS - attr.baseURI - 사용금지
DOM_Attribute JS - attr.childNodes - 사용금지
DOM_Attribute JS - attr.cloneNode() 메서드 - 사용금지
DOM_Attribute JS - attr.firstChild -
DOM_Attribute JS - attr.hasAttributes() 메서드 -
DOM_Attribute JS - attr.hasChildNodes -
DOM_Attribute JS - attr.insertBefore() 메서드 -
DOM_Attribute JS - attr.isEqualNode() 메서드 -
DOM_Attribute JS - attr.isSameNode() 메서드 -
27/89
목록
 홈  PC버전 로그인 일본어
그누앞단언어
그누뒷단언어
그외코딩언어
그누보드
제작의뢰
Q&A
커뮤니티
웹유틸
회원센터
홈짱닷컴 PC버전 로그인