Home  >  Article  >  Web Front-end  >  Introduction to the use of parseInt() method of global objects in JavaScript

Introduction to the use of parseInt() method of global objects in JavaScript

PHPz
PHPzforward
2016-05-16 17:08:161505browse

How to use the parseInt() method of the global object. The following is a detailed introduction for you. Friends who are interested should not miss it

<html> 
<head> 
<title>全局对象的parseInt() 方法</title> 
<script> 
/* 
parseInt() 函数可解析一个字符串,并返回一个整数。 
1、解析字符串,直到不能解析为止 
2、进制转化中,解析字符串,直到不能解析为止 
*/ 
document.write(parseInt("123") + "<br/>");//123 
document.write(parseInt("1abc23") + "<br/>");//1 
document.write(parseInt("123abc") + "<br/>");//123 
document.write(parseInt("abc") + "<br/>");//NaN 
document.write(parseInt("100",2) + "<br/>");//4,以二进制形式解析 
document.write(parseInt("123",2));//1,因为2、3不能解析 
</script> 
</head> 
<body> 
<p id="time"></p> 
</body> 
</html>

The above is the entire content of this chapter. For more related tutorials, please visitJavaScript video tutorial!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete