Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法搜索维度未知的关联数组并将所有空值更改为空字符串?
谢谢!
可能是这样的:
var objectNullToEmpty = function (obj) { for (key in obj) { if (obj[key] === null) { obj[key] = ''; } if (typeof obj[key] === 'object') { objectNullToEmpty(obj[key]); } } return obj; };