0、是否属于对象
const _toString = Object.prototype.toString;
const isPlainObject = (obj) => {
return _toString.call(obj) === '[object Object]';
}
const App = (props) => {
const { data } = props || {};
const nameList = [];
if (isPlainObject(data)) {
nameList = Object.keys(data);
}
}
1、把对象的key值提取到一个数组集合中
const deps = {
'数据部':[1,2,3],
'DT部':[5,8,12],
'行政部':[5,14,79],
'人事部':[3,64,105],
}
let member = Object.values(deps).flat(Infinity);
2、添加对象属性值
let obj = {};
let index = 1;
obj[`topic${index}`] = '话题内容';
3、输入框非空的判断
if((value??'') !== ''){
//...
}