“Js konvertieren Array in Objekt” Code-Antworten

JavaScript -Objekt TOARRAY

var obj = {"1":5,"2":7,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0}
var result = Object.keys(obj).map(function(key) {
  return [Number(key), obj[key]];
});

console.log(result);
Handsome Hare

JS -Array in Objekt

const names = ['Alex', 'Bob', 'Johny', 'Atta'];

// convert array to th object
const obj = Object.assign({}, names);

// print object
console.log(obj);

// {0: "Alex", 1: "Bob", 2: "Johny", 3: "Atta"}
Plain Pygmy

JS -Array, um mit Schlüssel zu gestalten

const arr = ['a','b','c'];
const res = arr.reduce((a,b)=> (a[b]='',a),{});
console.log(res)
Sleepy Squirrel

Konvertieren Sie das Array in JavaScript in Objekt

const array =    [ [ 'cardType', 'iDEBIT' ],
      [ 'txnAmount', '17.64' ],
      [ 'txnId', '20181' ],
      [ 'txnType', 'Purchase' ],
      [ 'txnDate', '2015/08/13 21:50:04' ],
      [ 'respCode', '0' ],
      [ 'isoCode', '0' ],
      [ 'authCode', '' ],
      [ 'acquirerInvoice', '0' ],
      [ 'message', '' ],
      [ 'isComplete', 'true' ],
      [ 'isTimeout', 'false' ] ];
      
const obj = Object.fromEntries(array);
console.log(obj);
Naughty Nightingale

Konvertieren Sie das Objekt in Array JavaScript

var object = {'Apple':1,'Banana':8,'Pineapple':null};
//convert object keys to array
var k = Object.keys(object);
//convert object values to array
var v = Object.values(object);
Dr. Hippo

Js konvertieren Array in Objekt

const names = ['Alex', 'Bob', 'Johny', 'Atta'];

const obj = Object.assign({}, names);
Reza

Ähnliche Antworten wie “Js konvertieren Array in Objekt”

Fragen ähnlich wie “Js konvertieren Array in Objekt”

Weitere verwandte Antworten zu “Js konvertieren Array in Objekt” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen