Recent posts

Recent comments

Archive

Calender

«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Math.floor() parseInt()
  
<script type="text/javascript">
var a = Math.floor( "12.34" ); 
var b = Math.floor( "56.78" ); 

var c = Math.floor( "-12.34" ); 
var d = Math.floor( "-56.78" ); 

var e = Math.floor( "12  34  56" ); 
var f = Math.floor( "   40   " ); 


var str = "<br />" + 
"a = " + a + "<br />" + 
"b = " + b + "<br />" + 
"c = " + c + "<br />"+ 
"d = " + d + "<br />" + 
"e = " + e + "<br />" + 
"f = " + f + "<br />"; 

document.getElementById( "demo1" ).innerHTML = str; 
</script>
<script type="text/javascript">
var a = parseInt( "12.34" ); 
var b = parseInt( "56.78" ); 

var c = parseInt( "-12.34" ); 
var d = parseInt( "-56.78" ); 

var e = parseInt( "12  34  56" ); 
var f = parseInt( "   40   " ); 


var str = "<br />" + 
"a = " + a + "<br />" + 
"b = " + b + "<br />" + 
"c = " + c + "<br />"+ 
"d = " + d + "<br />" + 
"e = " + e + "<br />" + 
"f = " + f + "<br />"; 

document.getElementById( "demo2" ).innerHTML = str; 
</script>


Math.floor() parseInt()
  
<script type="text/javascript">
var a = Math.floor( "034" ); 
var b = Math.floor( 034 ); 

var c = Math.floor( "0x34" ); 
var d = Math.floor( 0x34 ); 

var e = Math.floor( "3e4" ); 
var f = Math.floor( 3e4 ); 


var str = "<br />" + 
"a = " + a + "<br />" + 
"b = " + b + "<br />" + 
"c = " + c + "<br />"+ 
"d = " + d + "<br />" + 
"e = " + e + "<br />" + 
"f = " + f + "<br />"; 

document.getElementById( "demo3" ).innerHTML = str; 
</script>
<script type="text/javascript">
var a = parseInt( "034" ); 
var b = parseInt( 034 ); 

var c = parseInt( "0x34" ); 
var d = parseInt( 0x34 ); 

var e = parseInt( "3e4" ); 
var f = parseInt( 3e4 ); 


var str = "<br />" + 
"a = " + a + "<br />" + 
"b = " + b + "<br />" + 
"c = " + c + "<br />"+ 
"d = " + d + "<br />" + 
"e = " + e + "<br />" + 
"f = " + f + "<br />"; 

document.getElementById( "demo4" ).innerHTML = str; 
</script>


Math.floor() parseInt()
  
<script type="text/javascript">
var a = Math.floor( true ); 
var b = Math.floor( false ); 

var c = Math.floor( null ); 
var d = Math.floor( undefined ); 

var e = Math.floor( "" ); 
var f = Math.floor( new Date()  ); 


var str = "<br />" + 
"a = " + a + "<br />" + 
"b = " + b + "<br />" + 
"c = " + c + "<br />"+ 
"d = " + d + "<br />" + 
"e = " + e + "<br />" + 
"f = " + f + "<br />"; 

document.getElementById( "demo5" ).innerHTML = str; 
</script>
<script type="text/javascript">
var a = parseInt( true ); 
var b = parseInt( false ); 

var c = parseInt( null ); 
var d = parseInt( undefined ); 

var e = parseInt( "" ); 
var f = parseInt( new Date()  ); 


var str = "<br />" + 
"a = " + a + "<br />" + 
"b = " + b + "<br />" + 
"c = " + c + "<br />"+ 
"d = " + d + "<br />" + 
"e = " + e + "<br />" + 
"f = " + f + "<br />"; 

document.getElementById( "demo6" ).innerHTML = str; 
</script>


 
<script type="text/javascript">

var a = Math.floor( "00.0001" ); 

var b = parseInt( "00.0001" ); 

var str = "<br />" + 
"a = " + a + "<br />" + 
"b = " + b + "<br />"; 

document.getElementById( "demo7" ).innerHTML = str; 
</script>

참고로,
아래와 같이 작성한 경우에는, 오류가 나온다.

var a = Math.floor( 00.0001 );
var b = parseInt( 00.0001 );





이 내용이 도움이 되셨다면, 아래의 하트 버튼을 눌러주세요. *^^*