sudan kanakavel sudan kanakavel - 1 year ago 128
JSON Question

How to delete an entire column in an array using JavaScript

I have array of 3 columns (array has 6000 evalues and so each colum of array have 6000 values) in json file and store in variable called data. Using java script i need to store only first two columns of an array in a variable called edata. That is edata should contain array of two column of 6000 values.

That is 2 colum contain 6000 values each. Third colum should not be present.

Kindly help me in finding solution to it. I tried slice function but it only give 2 values as output i need 2 entire colums. that is from [[a,b,c],[a,b,c],[a,b,c],[a,b,c],[a,b,c]]............ to [[a,b],[a,b],[a,b],[a,b]]...........

url: "xxxxxxxxxxxxxxxxxxx",
type: 'GET',
context: document.body,
success: function(data){
// http call for end
var edata = data.slice(1,2);
var series= [{
name: 'Touches',
color: 'rgba(223, 83, 83, .5)',

data: edata

Answer Source

You can use the map function for this.

var edata = {
    return {field1: obj.field1, field2: obj.field2}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download