All Questions
Tagged with object ecmascript-6
1,091
questions
0
votes
2
answers
51
views
js common function which calculates and assign to object values?
Example of what i'm trying to achieve
I want to make an object in react which will calculate one its key value from other keys using this function and the 'this' keyword so that I can use this ...
0
votes
3
answers
41
views
How to filer an array of objects and return only one object based on a specific value
I have an array containing two plan objects:
[ { "id": "price_aehdw424i7rxyeqiquedwuy",
"name": "Monthly Plan",
"price": 2900,
"...
-1
votes
1
answer
207
views
How to replace the object array using simple filter and spread operators
I need a suggestion for the below code. The objective here is to remove the specific array if the mentioned menuKey is present.
Note: sdb.menu = 'account-links' (Declared in another file);
const { ...
0
votes
2
answers
359
views
Filter nested array in object based on specific values of another array [duplicate]
I have an array of Objects, and every object has an array of strings (tags), I need to filter the array of objects based on another array.
data: [
{
"id":"Nerium",
...
-1
votes
1
answer
36
views
How can we check key avaibality in objects? [duplicate]
const student= [
{
student_id: 0,
name: "Rhoda Salas",
checked:"checked"
},
{
student_id: 1,
name: "Jewell Avery"
},
{
...
3
votes
4
answers
4k
views
How to add prefix to object keys in javascript?
Lets say I have object:
{
cart: 4,
trolley: 10,
car: 2,
}
How can I turn it into:
{
shopping_cart: 4,
shopping_trolley: 10,
shopping_car: 2,
}
0
votes
3
answers
34
views
Is there a way to generate an object from another object by taking all its properties with except of one?
Having the initial object of this shape:
const initial = { a: 'a', b: 'b', c: 'c', d: 'd', ..., z: 'z' };
The result should contain all properties but without 'b' for example. I know there is a ...
-1
votes
1
answer
46
views
Intersection of two sets displays [object set]
How do I get to display the elements that make up the intersection of two sets without it displaying [object set] ?
const setA = new Set([1, 2, 3, 4]);
const setB = new Set([3, 4, 5, 6]);
...
-1
votes
5
answers
898
views
javascript Object.assign() without overriding fields
Is there any way to merge two objects, like Object.assign(a, b), but I want the same field in a keeps its origin value (without overriding from b).
a = {x: 1, y: 2}
b = {y: 3, z: 4}
Object.assign(a, ...
0
votes
1
answer
35
views
How can the expansion of 'users.data.object.email' to object be implemented in javascript [duplicate]
Say I have this string/array:
'users.data.object.email' / [users, data, object, email]
How can I convert this string/array to a javascript object?
For example from the above string/array, the object ...
0
votes
3
answers
59
views
How can I destructing array and group them as objects in another array in JS?
I have a result set from DB like below:
"result": [
{
"customerId": "20572696",
"totalIncome": "260000",
"...
-1
votes
1
answer
565
views
Arrow Function Created In An Object Returns undefined When Called Using .call() Method [duplicate]
i just created an object with an arrow function :
const user={
fName:"0xN1nja",
about:()=>{
return this.fName;
}
}
now, when i call that arrow function with .call() ...
0
votes
1
answer
35
views
How to replace object props inside array with other object
I have an array of objects like this one:
let arr1 = [{
"ref": 1,
"index": "300",
"data": {
"id": 10,
"status": {...
3
votes
2
answers
134
views
JavaScript function that returns an object
This function is supposed to return an object, however, the construction used below is unfamiliar to me. How does this function work?
function expect(value) {
return {
toBe: exp => console....
-2
votes
2
answers
383
views
Add property and copy array of objects into an nested objects
I would like to copy an array of objects in a nested object with new property. How can I use es6 to achieve something like this
I would like to copy:
['cat', 'Dog', 'monkey'] into
[{"text":&...