By nashw


2019-07-11 19:12:54 8 Comments

Pretty new to Javascript, but I think this is probably fairly easy.

I have 2 separate arrays, a and b. I would like to merge them into a single Javascript Object, c, with the form as follows:

const a = [4, 5, 7, 2, 8, 4]
const b = [ 1, 7, 2, 3, 5, 6]

const c = {[4,1],[5,7],[7,2]...}

Any simple way to do this in a couple lines?

Thanks!

0 comments

Related Questions

Sponsored Content

45 Answered Questions

[SOLVED] How to check if an object is an array?

69 Answered Questions

[SOLVED] What is the most efficient way to deep clone an object in JavaScript?

79 Answered Questions

[SOLVED] How do I remove a particular element from an array in JavaScript?

  • 2011-04-23 22:17:18
  • Walker
  • 5841387 View
  • 7285 Score
  • 79 Answer
  • Tags:   javascript arrays

30 Answered Questions

[SOLVED] How to append something to an array?

46 Answered Questions

38 Answered Questions

[SOLVED] How do I remove a property from a JavaScript object?

41 Answered Questions

[SOLVED] Sort array of objects by string property value

19 Answered Questions

[SOLVED] Checking if a key exists in a JavaScript object?

33 Answered Questions

[SOLVED] For-each over an array in JavaScript?

41 Answered Questions

[SOLVED] Detecting an undefined object property

Sponsored Content