This article describes the usage of commonly used system functions of js. Share it for your reference.
The specific code is as follows:
Copy the code as follows: <html>
<head>
</head>
<body>
<script type="text/javascript">
//1. The escape() function converts the string into unicode encoding common to each computer platform; decoding (turning back) uses enscape().
var str = 'Beauty Wang';
document.write(escape(str));
document.write("<br />");
//2. Convert strings to integers, or to floating point types. If the original string age does not start with a number, the result is NaN.
var age = "26.9hellow world";
document.write(parseInt(age));//parseInt() function
document.write("<br />");
document.write(parseFloat(age));//parseFloat() function
document.write("<br />");
//3. Determine whether a value/variable value is not a number.
var num = "30.9abc";
if(isNaN(num)){
document.write("num is a non-number");
}else{
document.write("num is a number");
}
document.write("<br />");
//4. Determine whether a value/variable value is finite
var result = 10/0;
if(isFinite(result)){
document.write("result variable has finite value");
}else{
document.write("result variable has infinite values");
}
</script>
</body>
</html>
I hope this article will be helpful to everyone's JavaScript programming.