jQuery其他的静态方法

  • trim(str)
  • isArray(obj)
  • isFunction(obj)
  • isWindow(obj)
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery中的其他静态方法</title>
<script
src="https://code.jquery.com/jquery-1.12.4.js"
integrity="sha256-Qw82+bXyGq6MydymqBxNPYTaUXXq7c8v3CwiYwLLNXU="
crossorigin="anonymous">
</script>
<script>
$(function () {
const str = " HelloWorld ";
const arr = [1, 3, 5, 7, 9];
const fun = function () {
};


//--- 是为了能够明显的看到空格
console.log("---" + str + "---");
//问题 如何去除字符串前后的空格?
console.log("---" + $.trim(str) + "---");

//判断传入的对象是不是 window
console.log($.isWindow(window));
console.log($.isWindow(arr));

//判断传入的对象是不是真数组(传入伪数组时,返回false)
console.log($.isArray(arr));

//判断传入的对象是不是一个函数
console.log($.isFunction(fun));
//jQury 本质是一个匿名函数
console.log($.isFunction(jQuery));


})
</script>
</head>
<body>

</body>
</html>

评论

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×