OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Create object from two arrays [duplicate]

  • Thread starter Thread starter 3nath
  • Start date Start date
3

3nath

Guest
How can I create an object from two arrays without using loops in JavaScript.

example:

Code:
array1 = [ 1, 2, 3, 4, 5 ];
array2 = [ 'A', 'B', 'C', 'D', 'E' ];

I want from below object

Code:
obj = {
    '1': 'A',
    '2': 'B',
    '3': 'C',
    '4': 'D',
    '5': 'E',
}

<p>How can I create an object from two arrays without using loops in JavaScript.</p>
<p>example:</p>
<pre><code>array1 = [ 1, 2, 3, 4, 5 ];
array2 = [ 'A', 'B', 'C', 'D', 'E' ];
</code></pre>
<p>I want from below object</p>
<pre><code>obj = {
'1': 'A',
'2': 'B',
'3': 'C',
'4': 'D',
'5': 'E',
}
</code></pre>
 

Latest posts

M
Replies
0
Views
1
MusicLovingIndianGirl
M
Q
Replies
0
Views
1
quora question
Q
Top