Home > Web Front-end > JS Tutorial > 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
Release: 2018-09-30 17:59:06
forward
1530 people have browsed it

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>
Copy after login

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

Related labels:
source:jb51.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template