javascript JSON. 转换 注意事项

JSON.stringify() 会舍弃 方法。。只有属性才会转换成 json 字符串,所以 用

JSON.stringify()=='{}' 来判断对象是否为空 是错误的!!!!

正确的做法 是  Object.keys(obj).length > 0 !!!!!!!!!!!!

猜你喜欢

转载自www.cnblogs.com/whm-blog/p/10237528.html