console.clear();
const data = {
a: {
c: 1
},
b: 2
};
function customizer(value, key) {
console.warn(value);
return value;
};
var obj = _.cloneDeepWith(data, customizer);
// console.log(obj);
//保留四位小数
// var number = 111;
// number = Number(String(number).replace(/^(.*\..{4}).*$/, "$1"));
// console.log(number);
// console.log(_.isEmpty([1, 2, 3]));
var list = [{
a: 2,
b: 1
},
{
a: 3,
b: 2
},
{
a: 4,
b: 3
}];
var appArray = _.uniqWith(list, _.isEqual); //相同取初见元素
console.info(appArray);
var appArray = _.uniqBy(list, 'b'); //相同取初见元素
console.info(appArray);
// console.info(_.multiply(10.2,100));
// console.info(10.2*10000/100)
function digitLength(num) {
// Get digit length of e
const eSplit = num.toString().split(/[eE]/);
const len = (eSplit[0].split('.')[1] || '').length - ( + (eSplit[1] || 0));
return len > 0 ? len: 0;
}
// console.info(digitLength(1.299));
// console.info(Math.round(0.105, 2)))
//左边大于右边,下边大于上边排序算法
isNotAscY = (data, a, sort = 'asc') => {
const list = data.map(item => item[a]);
if (sort === 'desc') list.reverse();
return list.some((item, i, arr) => {
const result = i == 0 ? false: item - arr[i - 1] <= 0;
return result;
});
};
isNotAscX = (list, a, b) => {
return list.some(item => {
const result = item[a] <= item[b];
return result;
});
};
console.info('1' - '12');
// ' '.split('').map((word) => console.log(word, word == true));
// ' '.split(' ').map((word) => console.log(word, word == true));
// '1 2'.split(' ').map((word) => console.log(word, word == true));
// '1 2'.split(' ').map((word) => console.log(word, Boolean(word)));
// '1 2'.split(' ').map((word) => console.log(word, word && true));
// '1 2'.split(' ').map((word) => console.log(word, word ? true : ''));
console.info([{}].map(item=>item))
console.info(_.fromPairs([['fred', [30]], ['barney', 40]]));
console.log([\[\]].test('[1,2]'))
console.log('[1,2]'.slice(1,-1).split(','))
console