Array to key/value JSON conversion I'm very new to Javascript...

Below is my code to convert Array to key/value JSON. Would like to know if there is a better way to achieve this or if I use any know bad practices.

An input: [10, [20.1, 20.2], 1]

The output:
{"channel_id":10, "payload":[20.1,20.2], "sequence":1}

My working code to generate the output:



let myArray = [10, [20.1, 20.2], 1]

class MyObject {
  constructor(a, b, c) {
    this.channel_id = a,
      this.payload = b,
      this.sequence = c;
  }
}

myObject = new MyObject(myArray[0], myArray[1], myArray[2])

console.log(JSON.stringify(myObject))
Not sure that a class definition makes a lot of sense here since you don’t really have any real behavior being defined in this class. 
Destructuring can also help you populate variables from the input array directly.
camelCase is generally preferred in JS vs. snake_case. 


For example you might simplify to something like this:

const conversionFn = ( [ channelId, payload, sequence ] ) =&gt; {  
  return { channelId, payload, sequence };
};