SimpleLilly 2018-11-07 07:47:15

二维数组动态定义,赋值。 例如创建一个N行2列的二维数组。

var xAng = new Array();
var yAng = new Array();
var zAng = new Array();

var testData=[
        [
            16.78940129001079,
            -27.740760700702637,
            142.5525627059617,
            1540544775000
        ],
        [
            2.370820197042365,
            10.531009693501936,
            200.7786693606271,
            1540544290000
        ],
        [
            4.370820197042365,
            5.531009693501936,
            300.7786693606271,
            1540544890000
        ]];
	    		var xAng = new Array(testData.length);
	    		var yAng = new Array(testData.length);
	    		var zAng = new Array(testData.length);

	    		for (var i = 0; i < xAng.length; i++) {
	    			xAng[i] = new Array(2);
	    			yAng[i] = new Array(2);
	    			zAng[i] = new Array(2);
	    			xAng[i][0] = testData[i][3];
	    			xAng[i][1] = testData[i][0];
	    			yAng[i][0] = testData[i][3];
	    			yAng[i][1] = testData[i][1];
	    			zAng[i][0] = testData[i][3];
	    			zAng[i][1] = testData[i][2];
	    		}
				
//xAng,yAng,zAng三个都是二维数组
//完成赋值后,在控制台中打印可看到是二维数组obj。

评论

trang chủ - Wiki
Copyright © 2011-2024 iteam. Current version is 2.137.1. UTC+08:00, 2024-11-05 20:39
浙ICP备14020137号-1 $bản đồ khách truy cập$