-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjs_global.html
More file actions
66 lines (55 loc) · 2.32 KB
/
js_global.html
File metadata and controls
66 lines (55 loc) · 2.32 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!--
* @由于个人水平有限, 难免有些错误, 还请指点:
* @Author: cpu_code
* @Date: 2020-10-18 11:42:57
* @LastEditTime: 2020-10-18 12:56:23
* @FilePath: \web\javascript\js_global\js_global.html
* @Gitee: [https://gitee.com/cpu_code](https://gitee.com/cpu_code)
* @Github: [https://github.com/CPU-Code](https://github.com/CPU-Code)
* @CSDN: [https://blog.csdn.net/qq_44226094](https://blog.csdn.net/qq_44226094)
* @Gitbook: [https://923992029.gitbook.io/cpucode/](https://923992029.gitbook.io/cpucode/)
-->
<!DOCTYPE html>
<html lang="ch">
<head>
<meta charset="UTF-8">
<title>gloabal对象</title>
<script>
/*
Global
1. 特点:全局对象,这个Global中封装的方法不需要对象就可以直接调用。 方法名();
*/
var str = "https://github.com/CPU-Code/呵呵";
// encodeURI():url编码
var encode = encodeURI(str);
document.write(encode + "<br>");
// decodeURI():url解码
var s = decodeURI(encode);
document.write(s + "<br>");
var str1 = "https://github.com/CPU-Code/呵呵";
//encodeURIComponent():url编码,编码的字符更多
var encode1 = encodeURIComponent(str1);
document.write(encode1 + "<br>");
//decodeURIComponent():url解码
var s1 = decodeURIComponent(encode1);
document.write(s1 + "<br>");
var str = "11";
// parseInt():将字符串转为数字
// 逐一判断每一个字符是否是数字,直到不是数字为止,将前边数字部分转为number
var number = parseInt(str);
number += 1;
document.write(number + "<br>");
var a = NaN;
document.write("a == NaN =" + a == NaN );
document.write("<br>");
// isNaN():判断一个值是否是NaN
// NaN六亲不认,连自己都不认。NaN参与的==比较全部问false
document.write("isNaN(a) = " + isNaN(a) + "<br>");
var jscode = "alert(cpucode);";
// eval():讲 JavaScript 字符串,并把它作为脚本代码来执行
eval(jscode);
</script>
</head>
<body>
</body>
</html>