Linked Questions
32 questions linked to/from Create an object from an array of keys and an array of values
8
votes
5
answers
8k
views
Zip arrays as keys and values of an Object [duplicate]
I have this data
var foo = ['US','MX','NZ'];
var foo1 = [12',13',17];
var Object = {};
Ive tried this thing
var Object = {foo:foo1}
but it is not working
when i arrayed the object using alert (...
6
votes
4
answers
7k
views
Create object from two arrays [duplicate]
How can I create an object from two arrays without using loops in JavaScript.
example:
array1 = [ 1, 2, 3, 4, 5 ];
array2 = [ 'A', 'B', 'C', 'D', 'E' ];
I want from below object
obj = {
'1': 'A',
...
1
vote
1
answer
74
views
How to merge two arrays to an object? [duplicate]
I have two arrays with the same length.
array1 = ['title', 'details', 'price', 'discount'];
array2 = ['product name', 'product details', 200, 20];
Want to convert them into one object like following
...
0
votes
1
answer
169
views
How to create json object out of two arrays [duplicate]
Having two arrays:
let values = ["52", "71", "3", "45", "20", "12", "634", "21"];
let names = ["apple", "...
0
votes
2
answers
87
views
Converting array and array of arrays into array of objects [duplicate]
I've been facing issues in making array of objects using array and array of arrays. In my scenario I'm having 400 cols and 5000 rows. Having col names in separate array and user data in array of ...
-2
votes
1
answer
73
views
How to merge two arrays to make an object [duplicate]
consider i have an array say
let arr1=["john","Bruce","Clent"];
and
let arr2=[55,33,22];
Then how can i make an object out of this in javascript
object should look like:{&...
0
votes
1
answer
16
views
How to assign keys to an object converted from array? [duplicate]
I have the following structure and I would like to change keys name from this
let FIELDS = ['id', 'first_name', 'last_name', 'email']
let {...obj} = ['123','John','Doe', null]
console.log(obj) // {0: ...
86
votes
21
answers
167k
views
Recursively looping through an object to build a property list
Situation: I have a large object containing multiple sub and sub-sub objects, with properties containing multiple datatypes. For our purposes, this object looks something like this:
var object = {
...
62
votes
14
answers
51k
views
Merge keys array and values array into an object in JavaScript
I have:
var keys = [ "height", "width" ];
var values = [ "12px", "24px" ];
And I'd like to convert it into this object:
{ height: "12px", width: "24px" }
In Python, there's the simple idiom dict(zip(...
0
votes
7
answers
15k
views
How to create key value pair using two arrays in JavaScript?
I have two arrays, keys and commonkeys.
I want to create a key-value pair using these two arrays and the output should be like langKeys.
How to do that?
This is array one:
var keys=['en_US','...
3
votes
2
answers
9k
views
Javascript Recursion for creating a JSON object
needing some advice on how to do this properly recursively.
Basically what I'm doing, is entering in a bunch of text and it returns it as JSON.
For example:
The text:
q
b
name:rawr
Returns:
[
"...
1
vote
3
answers
2k
views
How to combine 2 arrays into 1 object javascript
I have 2 arrays that i want to "reduce" into 1 object.
so for instance:
I have..
var originalData = [1,2,3];
var newData = [3,1,2];
i want to combine these two arrays into an object that looks ...
1
vote
3
answers
835
views
How to do one to one mapping of two arrays in karate
* def alphabets = ["a","b","c"]
* def number = ["1","2","3"]
So that the final mapped result should be
final =[{"a":"1"}...
4
votes
3
answers
282
views
How to join 2 arrays into an array of objects
I've got some headers and peopleData:
const headers = ["name", "age", "nationality"]
const peopleData = [
["John", 31, "Spanish"],
["Jane&...
0
votes
5
answers
958
views
Use Destructuring to turn two arrays of strings into a key pair object
I've got two arrays of strings of equal length, and I want to make a key:pair object out of them, like:
INPUT:
let words1 = ["foo", "loo", "who"];
let words2 = ["bar&...