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

47 Answered Questions

86 Answered Questions

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

  • 2011-04-23 22:17:18
  • Walker
  • 6030932 View
  • 7509 Score
  • 86 Answer
  • Tags:   javascript arrays

20 Answered Questions

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

  • 2009-07-08 13:21:32
  • Adam Ernst
  • 1768935 View
  • 2695 Score
  • 20 Answer
  • Tags:   javascript object

47 Answered Questions

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

42 Answered Questions

[SOLVED] Detecting an undefined object property

33 Answered Questions

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

41 Answered Questions

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

69 Answered Questions

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

41 Answered Questions

[SOLVED] Sort array of objects by string property value

30 Answered Questions

[SOLVED] How to append something to an array?

Sponsored Content