All Questions
Tagged with object ecmascript-6
1,090
questions
0
votes
2
answers
31
views
I'm trying to extract the values of an object using destructuring assignment, the age variable says undefined. What I'm doing wrong?
const obj = {
firstUser: {
name: {
firstName: 'John',
lastName: 'Doe',
},
age: 32,
}
}
const {
firstUser: {
name: {
lastName: Lname
}
},
age
} = obj;
...
0
votes
0
answers
94
views
Getting circular object in map function
I have a big array of objects, in which I have to use two particular object keys for each element custom_attributes and custom_options. For each attribute one flavor from custom_options will be added ...
0
votes
2
answers
43
views
How to create an array that has in each index a string depending on the data type?
I have an array with an object nested in it. I'm trying to use map() to create an array that has in each index the string "war" or "peace". The string "war" if the name ...
1
vote
5
answers
1k
views
Filter/Reduce array of objects into a new object based on day
Consider the following array of objects:
const data = [
*{...more data from previous dates}*,
{
unixDate: 1650348034, //yesterday
dateTime: Tue Apr 19 2022 23:00:34,
...
0
votes
2
answers
200
views
How to get array of objects by object and arrays in javascript
For the array of object, compare with object and list array using javascript
should get the array of objects based on below conditions
itemvalue and idvalue same, from that check arrobj cid has same ...
4
votes
3
answers
1k
views
How can I spread array elements into an object as the keys, and define some value for them?
Let say I have an array:
const arr = ['a', 'b, 'c'];
I want to create an object like this:
{ 'a': true, 'b': true, 'c': true}
How can I do this?
const obj = {...arr: true}
did not work
0
votes
4
answers
216
views
Converting object values and properties into an array
How to convert an object with names and values into an array of object just like the below format.
'result' : { "name1" : "Angle", "name2" : "Demon", "...
-1
votes
1
answer
92
views
How to combine array of objects with common id in each object with ES6 functions [closed]
Attaching the input and output formats.
`
//Input
[{"id":"146","catId":"25"},
{"id":"200","catId":"25"},
{"id":...
0
votes
2
answers
93
views
how to create a multiple object value, if item is an arrary of arrays [[arr1],[arr2],[arr3,]
I have an object like this:
const objects = {
Battery: {
batteryDetailsKey: ["serial_no", "type", "part_no"],
batteryDetailsVal: ["HJ3CA19347410218LJ98 151 ...
0
votes
2
answers
895
views
How to turn 2 arrays into an object with key value pairs
I have an object which contains 2 objects with properties:
const objects = {
Battery: {
batteryDetailsKey: ['serial_no', 'type', 'part_no'],
batteryDetailsVal: [
'HJ3CA19347410218LJ98 ...
0
votes
2
answers
63
views
How to combine object properties on the sibling properties
I have an array of objects like this which i've read and parsed from a csv file.
const csvDataObjects = [
{
Battery: 'Battery',
batteryDetailsKey: ['Serial Number', 'Type', 'Part Number'],
...
0
votes
1
answer
236
views
How to get a data from an object inside of a function (JS)
let's say that I have a function that includes an object
const someFunc =props=> ({
styles:{
somedata: 'somedata:',
},
infoSectionValue: {
bold: true,
},
images:{
donut: props.donut_base64,
icon: ...
0
votes
3
answers
477
views
Update a JavaScript object recursively using values from another object
I would like to add some data to a nested JavaScript object, however I do not know how much of the object tree already exists. I want to add the structure if it is not there, but also keep the same ...
0
votes
2
answers
258
views
how to deep copy a JavaScript object from another without adding new properties
Here I have a default object with nested properties for eg -
default = {
key1: val1;
key2: {
key3: val3,
key4: val4
}
}
and a new object with new values for same properties as above and some ...
1
vote
1
answer
1k
views
ES6 typescript class create object of itself inside
I have created a class and inside that class i want to create an array that consist of object of itself. In normal javascript if achieve it as follow
class Person{
constructor(name){
...