fengorz
V2EX  ›  Node.js

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

  •  
  •   fengorz · Oct 16, 2019 · 6695 views
    This topic created in 2577 days ago, the information mentioned may be changed or developed.
    // 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 replies  •  2019-11-16 01:58:42 +08:00
    DecadentF
    DecadentF
    Oct 16, 2019
    1
    就是定义这两个字段
    hezhuowei
    hezhuowei
    Oct 21, 2019
    2
    let obj = {};
    let content; 的意思
    liaotuo
    liaotuo
    Oct 23, 2019
    3
    和 C 语言一样,定义两个变量
    xcstream
    xcstream
    Nov 16, 2019
    4
    定义一个空的变量
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1532 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 23:35 · PVG 07:35 · LAX 15:35 · JFK 18:35
    ♥ Do have faith in what you're doing.