Skip to content
Advertisement

Tag: object

how javascript handles variables in objects?

I have a question about declaring a variable in an object. Assuming that global or window is also an object, why is it not possible to declare a variable using let in an object that is a child of the window object? I do not understand that. Thanks for the answer and sorry for the English but I hope you

Overwrite array object if already present else add to array

When I run this example I expect the elementThatAllreadyExist to overwrite the existing object with the name test1 which it does correctly. When I run the example with arr2, I expect the newElement element to be added to the array since no object with the name “test33” exists in the array, but no element is added to the array. Why

Filter array object by type and compare key

I have two arrays, in one (aux) I get key and value. In the second array of objects (result) I have the attribute “correlati” and what I’m looking for is that if the key of the array “aux” is equal to the attribute “correlati” then it pushes that result in a new array that looks like the following : code:

Looping over an object to change values inside

I am trying to send an object to an api and my object contains arrays that I want to turn into strings. However I am having trouble returning the new object with the arrays turned to strings. My goal is to have a copy of the original object with all the arrays turned into strings. Answer You are not assigning

js: fill object with array elements using reduce()

trying to learn reduce() but can’t understand it well yet. Maybe someone from you could help me with my problem. I have an object with defined keys and an array. I would like to fill up the objects keys with the arrays values using reduce(). My sandbox LINK Till now I tried something like this: expected result: Thanks for any

how to store the value of a key for a object and pass it to the function which is a value of another key in the same object

In the above object inside dateFilter for value i am using a calculateAverage function to get the value i need to pass the same value as parameter for calculatePercentage which is a value for percentage key in the same object how to store the calculateAverage at dateFilter and pass it to calculatePercentage so that i can avoid calculating average two

Advertisement