Switch language
zh
Switch theme
Light

js-对象名是一个变量时,-怎么获取当前对象

    var j1 = {
        'j11': 'a',
        'j12': 'b',
        'j13': 'c',
    };

    var j2 = {
        'n1': 'j1',
        'n2': 'j2',
    };

    var obj = {
        j1: j1
    };

    var x = 'n1';
    console.log(j2[x]['j11']);//undefined
    console.log(obj[j2[x]]['j11']);// a

// ? 如何直接通过对象名同名字符串来获取对象 ?
🍀