V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
fengorz
V2EX  ›  Node.js

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

  •  
  •   fengorz · 2019-10-16 14:33:05 +08:00 · 5250 次点击
    这是一个创建于 1647 天前的主题,其中的信息可能已经有所发展或是发生改变。
    // 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;
    }
    4 条回复    2019-11-16 01:58:42 +08:00
    DecadentF
        1
    DecadentF  
       2019-10-16 18:01:15 +08:00
    就是定义这两个字段
    hezhuowei
        2
    hezhuowei  
       2019-10-21 18:03:43 +08:00
    let obj = {};
    let content; 的意思
    liaotuo
        3
    liaotuo  
       2019-10-23 11:45:06 +08:00
    和 C 语言一样,定义两个变量
    xcstream
        4
    xcstream  
       2019-11-16 01:58:42 +08:00
    定义一个空的变量
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2387 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 16:06 · PVG 00:06 · LAX 09:06 · JFK 12:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.