search

Home  >  Q&A  >  body text

javascript eval

An object is defined in the module, such as: let a = {}, how can we find the object a through the string 'a'?

淡淡烟草味淡淡烟草味2702 days ago746

reply all(2)I'll reply

  • 为情所困

    为情所困2017-07-05 11:04:32

    // eval不好吗
    var a = {b:1};
    var str = 'a';
    console.log(eval(str))

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-07-05 11:04:32

    Search locally or globally

    reply
    0
  • Cancelreply