$ .type()、$ .isArray()、 $ .isFunction()、$ .isWindow()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>温故而知“心”</title>
</head>
<body>
</body>
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script>
console.log( $.type(undefined) )
console.log( $.type("abc") )
console.log( $.type(123) )
console.log( $.type(true) )
console.log( $.type(function() {}) )
console.log( $.type(null) )
console.log( $.type({}) )
console.log( $.type([1, 2, 3, 4]) )
console.log( $.type(new Date()) )
console.log( $.type(new Number) )
console.log( $.type(new Person()) )
function Person(){}
const arrays = [1, 2, 3];
console.log( $.isArray(arrays) )
function fn(){}
console.log( $.isFunction(fn) )
console.log( $.isWindow(window) )
const text = " 1 2 3 ";
console.log(text)
console.log( $.trim(text) )
</script>
</html>
$.noConflict()防止冲突
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>温故而知“心”</title>
<style>
.demo {
width: 100px;
height: 100px;
background-color: #ff0000;
}
</style>
</head>
<body>
<div class="demo"></div>
</body>
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script>
const $C = $.noConflict();
$C('.demo').css({ backgroundColor: '#0000ff' })
</script>
</html>
$ .each() 、$.map()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>温故而知“心”</title>
<style></style>
</head>
<body>
</body>
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script>
const arr = [1, 2, 3];
$.each(arr, function (index, ele) {
console.log(index, ele)
})
const cont = $.map(arr, function (index, ele) {
return ele * index
})
console.log(`cont`, cont)
</script>
</html>