标签:index 常用 函数 数组 month str Date new js
清除数组空格
removeEmptyArrays(arr) {
// 使用filter方法移除空数组
// isArray方法检查元素是否为数组,length属性检查数组是否为空
return arr.filter(item => Array.isArray(item) && item.length > 0);
},
清除数组空null
let newArr=syy.filter(Boolean)
字符串以某个字符开始截取
num(str){
const index = str.indexOf('<')
return index!==-1 ?str.substring(0,index):str;
}
let currentDate = new Date();//创建时间
let currentDay = currentDate.getDate();//获取当前日期是当月的第几天
// 获取该月天数
function getMonthNum(month) {
dateList = []
var d = new Date();
var curMonthDays = new Date(d.getFullYear(), month || (d.getMonth() + 1), 0).getDate();
for (let i = 0; i < curMonthDays; i++) {
dateList.push(i + 1)
}
}
function getDaysInMonth(year, month) {//获取日期当月的天数(年,月)
return new Date(year, month, 0).getDate();
}
标签:index,
常用,
函数,
数组,
month,
str,
Date,
new,
js
From: https://www.cnblogs.com/7788mmhh/p/18096705