2024年07月30日
1、删除当前页面的url中flag参数
function urlDel(name){
var url = window.location;
var baseUrl = url.origin + url.pathname + "?";
var query = url.search.substr(1);
if (query.indexOf(name)>-1) {
var obj = {}
var arr = query
2024年07月30日
function isChinese(obj) {
if (/.*[\u4e00-\u9fa5]+.*$/.test(obj)){
return '是中文';
}
return '不是中文';
}
var name = '前端入门www建站1231教程'
var url = 'http://lmcjl.com'
var num = 12345678
console.log(
2024年07月30日
1、中文字符
var pattern = /[\u4e00-\u9fa5]/;
var str = "建站教程";
console.log(pattern.test(str));
2、双字节字符
var pattern = /[^\x00-\xff]/;
var str = "建站教程ipkd";
console.log(pattern.test(str));
3、空白行
var patt
2024年07月30日
用到了递归思路,从第一层一直去循环数组,从而获取当前数组是几维数组,代码如下:
var arr = [1,2,3,[1,2,3,1,3,[1,2,3,6,4,[1,2,3,1]]],2]
var arrNum = 1;
//方法:
function multiArr(arr){
for (i=0;i<arr.length;i++){
if(arr[i] instanceof Array){
arrNum++;
arr = ar
2024年07月30日
Ps:Longhand表示常规写法,Shorthand表示简写形式
1、当同时声明多个变量时,可简写成一行
//Longhand
let x;
let y = 20;
//Shorthand
let x, y = 20;
2、利用解构,可为多个变量同时赋值
//Longhand
let a, b, c;
a = 5;
b = 8;
c = 12;
//Shorthand
let [a, b, c] = [5, 8, 1