📂 JAVASCRIPT/Number & Math
[ 자바스크립트 ] isNaN() VS Number.isNaN() 🕔 2016. 3. 6. 00:01
<script type="text/javascript">
// Number.isNaN() 함수가 적용되지 않을 때 추가할 내용 ( ie 11 이하 )
if ( ! Number.isNaN ){
Number.isNaN = function isNaN ( value ){ return value !== value; };
}
</script>
<p id="type"> </p>
<p id="global"> </p>
<p id="number"> </p>
<script type="text/javascript"> function testing (){ var value = "NaN"; var type = typeof value; var global = isNaN( value ); var number = Number.isNaN( value ); document.getElementById( "type" ).innerHTML = type; document.getElementById( "global" ).innerHTML = global; document.getElementById( "number" ).innerHTML = number; } </script>
<p id="type"> </p>
<p id="global"> </p>
<p id="number"> </p>
<script type="text/javascript"> function testing (){ var value = NaN; var type = typeof value; var global = isNaN( value ); var number = Number.isNaN( value ); document.getElementById( "type" ).innerHTML = type; document.getElementById( "global" ).innerHTML = global; document.getElementById( "number" ).innerHTML = number; } </script>
<p id="type"> </p>
<p id="global"> </p>
<p id="number"> </p>
<script type="text/javascript"> function testing (){ var value = undefined; var type = typeof value; var global = isNaN( value ); var number = Number.isNaN( value ); document.getElementById( "type" ).innerHTML = type; document.getElementById( "global" ).innerHTML = global; document.getElementById( "number" ).innerHTML = number; } </script>
<p id="type"> </p>
<p id="global"> </p>
<p id="number"> </p>
<script type="text/javascript"> function testing (){ var value = null; var type = typeof value; var global = isNaN( value ); var number = Number.isNaN( value ); document.getElementById( "type" ).innerHTML = type; document.getElementById( "global" ).innerHTML = global; document.getElementById( "number" ).innerHTML = number; } </script>
<p id="type"> </p>
<p id="global"> </p>
<p id="number"> </p>
<script type="text/javascript"> function testing (){ var value = [ ]; var type = typeof value; var global = isNaN( value ); var number = Number.isNaN( value ); document.getElementById( "type" ).innerHTML = type; document.getElementById( "global" ).innerHTML = global; document.getElementById( "number" ).innerHTML = number; } </script>
<p id="type"> </p>
<p id="global"> </p>
<p id="number"> </p>
<script type="text/javascript"> function testing (){ var value = { }; var type = typeof value; var global = isNaN( value ); var number = Number.isNaN( value ); document.getElementById( "type" ).innerHTML = type; document.getElementById( "global" ).innerHTML = global; document.getElementById( "number" ).innerHTML = number; } </script>
<p id="type"> </p>
<p id="global"> </p>
<p id="number"> </p>
<script type="text/javascript"> function testing (){ var value = "abc"; var type = typeof value; var global = isNaN( value ); var number = Number.isNaN( value ); document.getElementById( "type" ).innerHTML = type; document.getElementById( "global" ).innerHTML = global; document.getElementById( "number" ).innerHTML = number; } </script>
<p id="type"> </p>
<p id="global"> </p>
<p id="number"> </p>
<script type="text/javascript"> function testing (){ var value = "123abc"; var type = typeof value; var global = isNaN( value ); var number = Number.isNaN( value ); document.getElementById( "type" ).innerHTML = type; document.getElementById( "global" ).innerHTML = global; document.getElementById( "number" ).innerHTML = number; } </script>
<p id="type"> </p>
<p id="global"> </p>
<p id="number"> </p>
<script type="text/javascript"> function testing (){ var value = "abc123"; var type = typeof value; var global = isNaN( value ); var number = Number.isNaN( value ); document.getElementById( "type" ).innerHTML = type; document.getElementById( "global" ).innerHTML = global; document.getElementById( "number" ).innerHTML = number; } </script>
이 내용이 도움이 되셨다면, 아래의 하트 버튼을 눌러주세요. *^^*
'JAVASCRIPT > Number & Math' 카테고리의 다른 글
[ 자바스크립트 ] Number() VS parseFloat() (0) | 2016.03.16 |
---|---|
[ 자바스크립트 ] Number.isSafeInteger() (0) | 2016.03.06 |
[ 자바스크립트 ] isFinite() VS Number.isFinite() (0) | 2016.03.06 |
[ 자바스크립트 ] 천단위 콤마 추가하기 (0) | 2015.05.30 |
[ 자바스크립트 ] 구구단표 만들기 (2) | 2015.05.06 |