Top "Javascript-objects" questions

Use this tag for questions related to JavaScript objects.

Replace a one javascript object with another object

On page load I am creating two Javascript Objects, objDemo1 and objDemo1Backup where the latter is simply an exact …

javascript reset javascript-objects
Javascript ES6 spread operator on undefined

While developing my react App, I needed to send a conditional prop to a component so I found somewhere a …

javascript ecmascript-6 javascript-objects spread-syntax
Remove all elements from object except specified key?

I have an object: "languages": { "en":["au", "uk"], "de":["de"], .... } How can I remove everything but a specified key, so …

javascript javascript-objects
Maps vs Objects in ES6, When to use?

Ref: MDN Maps Use maps over objects when keys are unknown until run time, and when all keys are the …

javascript ecmascript-6 javascript-objects
Mongoose/MongoDB result fields appear undefined in Javascript

Is there something that I'm missing that would allow item to log as an object with a parameter, but when …

javascript mongodb mongoose javascript-objects function-prototypes
Add property to object when it's not null

I'm working on a small API and I want to update the data using HTTP PATCH REQUEST without using a …

javascript typescript javascript-objects
Jest.js tests don't pass when expected/received values are objects

I'm testing this reducer: const todo = (state = {}, action) => { switch(action.type) { case 'ADD_TODO': return { id: action.id, text: …

unit-testing redux javascript-objects jestjs
Anonymous class instance ---- is it a bad idea?

In ES6 we can do anonymous class: var entity = class { } But we can also instantiate it: var entity = new class { …

javascript oop ecmascript-6 javascript-objects anonymous-function
Invoke a javascript object method from within a callback

I define the following MyClass and its methods in a user script: function MyClass() { this.myCallback = function() { alert("MyClass.myCallback()"); }; …

javascript callback javascript-objects
JS associative object with duplicate names

ok, so I have an object like: var myobject = { "field_1": "lorem ipsum", "field_2": 1, "field_2": 2, "field_2": 6 }; as you see there are …

javascript object duplicates javascript-objects associative