基本数据类型

字符串

//判断字符串中是否有莫哥值
msg.includes('start')

数组

//增
arr.push(1221)
//查
arr.indexOf('element')
//对象数组去重
let arrObj = [
    {Action: "打开页面", Time: "2022-06-08 18:31:17", Msg: "跳转成功", Msglen: 1, Success: true},
    {Action: "打开页面", Time: "2022-06-08 18:31:17", Msg: "跳转成功", Msglen: 1, Success: true},
		{Action: "打开页面", Time: "2022-06-08 18:32:17", Msg: "跳转成功", Msglen: 1, Success: true},
    {Action: "输入文本", Time: "2022-06-08 18:31:18", Msg: "输入falcon成功", Msglen: 1, Success: true},
    {Action: "输入文本", Time: "2022-06-08 18:31:18", Msg: "输入falcon成功", Msglen: 1, Success: true},
		{Action: "输入文本", Time: "2022-06-08 18:32:18", Msg: "输入falcon成功", Msglen: 1, Success: true},
    {Action: "获取页面文字", Time: "2022-06-08 18:31:18", Msg: "获取元素内容成功", Msglen: 1, Success: true},
    {Action: "获取页面文字", Time: "2022-06-08 18:31:18", Msg: "获取元素内容成功", Msglen: 1, Success: true},
    {Action: "关闭页面", Time: "2022-06-08 18:31:49", Msg: "关闭浏览器成功", Msglen: 1, Success: true},
    {Action: "关闭页面", Time: "2022-06-08 18:31:49", Msg: "关闭浏览器成功", Msglen: 1, Success: true},
		{Action: "测试", Time: "2022-06-08 18:31:49", Msg: "关闭浏览器成功", Msglen: 1, Success: true}
];
let map = new Map();
for (let item of arrObj) {
    if (!map.has(item.Time+item.Action)) {
        map.set(item.Time+item.Action, item);
				// map.set(item.Time, item);
    };
};
arr = [...map.values()]; //去重后数组

for (let item of arr) {
	tempdata = ''
	tempdata += '['+ item.Action +'] '+'['+ item.Time +'] '+'['+ item.Msg +'] '+'['+ item.Success +'] '
	console.log(tempdata)
}
console.log(arr);

js与jquery

  • $(selector) 可以简单地用querySelectorAll()替换;
  • CSS类名切换,可以通过Element.classList实现;
  • CSS现在支持在样式表中定义视觉动画,无需使用JavaScript;
  • $.ajax请求可以用Fetch标准实现;
  • addEventListener()接口已经十分稳定,足以跨平台使用;
  • 可以用一个轻量级的库,来封装事件代理模式;
  • jQuery提供的一些语法糖,已随着JavaScript语言的发展,而变得多余。
版权声明:本文为hanwang原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/hanwang/p/16285745.html