从字符串变量中检索数组值

时间:2018-11-07 07:38:18

标签: javascript jquery arrays

我在JQuery的字符串变量中有一个数组名称。我想从此字符串变量获取数组值。

var f_1=["1","2","3","4"];
var f_2=["1","2","3","4"];
var f_3=["1","two","3","4",];
var f_4=["fname","lname","true","false","1"];       
var f_array=["f_1","f_2"];
populate_array();
function populate_array(){
        var x=f_array[0];
        var num= [];
        num=new Array(x).slice(0);          
        console.log("array values "+Array(f_1).slice(0));           
        for(var i=1;i<4;i++){               
            console.log(num[i]+"   "+f_array[0][i]);
        }
}

我得到num为未定义,而f_array [0] [i]为_。如何从f_array [0]分配f_1的值?

1 个答案:

答案 0 :(得分:0)

请记住,这并不是一件很明智的事情,但是migrationBuilder.AddForeignKey( name: "FK_Table2_Table1_Table1Id", table: "Table2", column: "Table1Id", principalTable: "Table1", principalColumn: "Id", onDelete: ReferentialAction.Cascade); 可以解决您的问题

eval