fengorz
V2EX  ›  Node.js

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

  •  
  •   fengorz · Oct 16, 2019 · 6251 views
    This topic created in 2427 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
        1
    DecadentF  
       Oct 16, 2019
    就是定义这两个字段
    hezhuowei
        2
    hezhuowei  
       Oct 21, 2019
    let obj = {};
    let content; 的意思
    liaotuo
        3
    liaotuo  
       Oct 23, 2019
    和 C 语言一样,定义两个变量
    xcstream
        4
    xcstream  
       Nov 16, 2019
    定义一个空的变量
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2922 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 15:12 · PVG 23:12 · LAX 08:12 · JFK 11:12
    ♥ Do have faith in what you're doing.