这种写法是啥意思 let obj = {}, content;

2019-10-16 14:33:05 +08:00
 fengorz
// content 在上面也没有被定义,后端开发人员初学前端,有点蒙蔽。
export const getStore = (params = {}) => {
let {
name,
debug
} = params;
name = keyName + name
let obj = {},
content;
obj = window.sessionStorage.getItem(name);
if (validatenull(obj)) obj = window.localStorage.getItem(name);
if (validatenull(obj)) return;
try {
obj = JSON.parse(obj);
} catch{
return obj;
}
if (debug) {
return obj;
}
if (obj.dataType == 'string') {
content = obj.content;
} else if (obj.dataType == 'number') {
content = Number(obj.content);
} else if (obj.dataType == 'boolean') {
content = eval(obj.content);
} else if (obj.dataType == 'object') {
content = obj.content;
}
return content;
}
5315 次点击
所在节点    Node.js
4 条回复
DecadentF
2019-10-16 18:01:15 +08:00
就是定义这两个字段
hezhuowei
2019-10-21 18:03:43 +08:00
let obj = {};
let content; 的意思
liaotuo
2019-10-23 11:45:06 +08:00
和 C 语言一样,定义两个变量
xcstream
2019-11-16 01:58:42 +08:00
定义一个空的变量

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/609900

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX