1.base64编码方法:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="crypt0.js"></script>
<!-- 第三方加密库 crypto -->
</head>
<body>
<script>
// Base64 函数 js逆向常见
// let values = 'hello';
// console.log(btoa(values)); //aGVsbG8=
// let res = 'aGVsbG8=';
// console.log(atob(res));//hello
//https://www.jianshu.com/p/a47477e8126a
// let values = 'hello'
// let trans = CryptoJS.enc.Utf8.parse(values);
// // alert(trans)
// let encryped = CryptoJS.enc.Base64.stringify(trans);
// alert(encryped); //aGVsbG8=
// //第三方库解码方法
// let trans_encryped = CryptoJS.enc.Base64.parse(encryped);
// let res = trans_encryped.toString(CryptoJS.enc.Utf8)
// alert(res)
let value = 'hello world'
// let encryped = CryptoJS.MD5(value);
// console.log(encryped.toString());
let encryped = CryptoJS.SHA256(value);
console.log(encryped.toString());
console.log(encryped.toString(CryptoJS.enc.Base64));
// function Base66(){
// this.encode = function(val){
// return val; //编码在这里写
// }
// this.decode = function(val){
// return val; //解码逻辑在这里写
// }
// }
// encryed = new Base66();
// encryped.encode("dafddasfdsf")
// encryed.decode("adfadfdf")
</script>
</body>
</html>
2.jquery之var:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://lib.baomitu.com/jquery/3.5.0/jquery.js"></script>
<script>
$(document).ready(function(){ //页面加载完毕以后再执行里边的js代码
$("button").click(function(){
$("#test").val("风口上的浪子");
alert($("#test").val());
})
})
</script>
</head>
<body>
<div>Your name:
<input type="text" name="username" id="test" value="kangbazi">
<button>点我改变输入框的值</button>
</div>
</body>
</html>
3.json对象转换:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>json</title>
</head>
<body>
<script>
//json本质就是字符串
var person = {
'username':'kangbazi',
'password':666666,
};
//对象转字符串 stringify
console.log(JSON.stringify(person),typeof(JSON.stringify(person)));
//{"username":"kangbazi","password":666666}
//字符串转对象 parse
var params = '{"username":"kangbazi","password":666666}';
console.log(JSON.parse(params),typeof(JSON.parse(params)));
</script>
</body>
</html>
4.return语法:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
function _hahaValue(v){
let _token = v.join('-');
return _token;
}
// console.log( _hahaValue([1,2,3,4]));
function first(){
// console.log("别说话,吻我");
return 'first'
}
var second = function(){
// console.log("调用我,我会修电脑,还是专业摄影师");
return 'second'
}
function _tokenValue(v){
let _token = v.join('-');
return second(),
first(),
_token;
}
console.log(_tokenValue([1,2,3,4]));
</script>
</body>
</html>
5.函数相关操作:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>函数</title>
<script src="https://lib.baomitu.com/jquery/3.5.0/jquery.js"></script>
</head>
<body>
<script>
//函数自动执行
// (function test(){
// console.log('自动执行')
// })()
// $(function test(){
// console.log('哥也能自动执行')
// })
// function first(){
// return 'first';
// }
// function second(){
// console.log(first());
// }
// second();
// var box = function(){
// return '定义函数'
// }
// var person = {
// 'username':'haha',
// 'car':function(){
// return '我看中的不是他的钱,而是能够单手开法拉利的能力'
// }
// }
// alert(person.username)
// alert(person.car())
</script>
</body>
</html>
6.数组操作:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
let myarray = [];
let test = new Array();
//栈方法 操作的是数组的结尾
//队列方法 操作的是数组的开头
test.push([12,34,56],888) //[[12,34,56],88]
// console.log(arrays2)
// console.log(test.pop());
test.unshift('a','b','c');
// console.log(test.shift());
//数组转字符串
// console.log(test.join(';'));
//toString()
// console.log(typeof test.toString());
//concat 拼接数组
//slice
//splice 数组增删改
let value = 666;
// console.log(value.toString(2)); //1010011010 字符串转二进制
// console.log(value.toString(8)); //1232 字符串转8进制
// console.log(value.toString(16)); //29a 字符串转 16进制
let str = false
// console.log(typeof str.toString()); //布尔值转字符串
console.log(toString.call(str)) //[object Boolean]
let arr = [1,2,3]
// console.log(arr instanceof Array); //true
// console.log(toString.call(arr)) //[object Array]
</script>
</body>
</html>
7.字符串和unicode相互转换:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>字符串、Unicode值相互转</title>
</head>
<body>
<script>
let value = 'b'; //字符串转Unicode
console.log(value.charCodeAt());//98
//a 97 A 65
let res = String.fromCharCode(99,103,72,80,66); //cgHPB
console.log(res);
</script>
</body>
</html>
万水千山总是情,点个关注行不行。