Eval response.d in Jquery Ajax

后端 未结 1 1978
盖世英雄少女心
盖世英雄少女心 2021-01-28 17:54

What is the point of doing this:

var resultsArray = (typeof response.d) == \'string\' 
    ? eval(\'(\' + response.d + \')\') : response.d;

ins

相关标签:
1条回答
  • 2021-01-28 18:21
    var resultsArray =                  /* assign a value to resultsArray...        */
      (typeof response.d) == 'string' ? /* ...if the type of response.d is string   */
      eval('(' + response.d + ')')    : /* ...then evaluate it as if it was JS code */
      response.d;                       /* ...else just assign it unaltered         */
    
    0 讨论(0)
提交回复
热议问题