javascript / Jquery converted into a string variable name

var A = [ 'A', 'B', 'C' ]
 var obj = {}
 for (I = 0; I <a.length; I ++ ) { 
    obj [A [I]] = "ABC" +. 1 
} 
Alert (obj.a) 
 Alert (obj.b) 
  Alert (obj.c) 
 
If you do not want to use the obj 
may be 
for (I = 0; I <a.length; I ++ ) { 
    window [A [I]] = "ABC" . 1 + 
} 
Alert (A) 
 Alert (B) 
  Alert (C) 
, but such use is not recommended, preferably the first method.

Source: https://zhidao.baidu.com/question/1366905120567757419.html

Guess you like

Origin www.cnblogs.com/WeiYongZhi/p/11584928.html
Recommended