Questions tagged [javascript-objects]
Use this tag for questions related to JavaScript objects.
6,368
questions
0
votes
0
answers
13
views
how to access value of an object that key is in variable [duplicate]
Trying to solve this:
function (key, value2) {
var obj = {}
obj.key = 'value2'
}
and not being able to access the value of first parameter using obj.key
theres any way to access it?
1
vote
5
answers
37
views
Overwrite an Object inside an Array of Objects
What is the best way to overwrite an object inside an array of objects?
I would like to have only one object per username, in this case in the initial arr Francis has a showMessage to true but ...
-1
votes
0
answers
19
views
i have a case, how to sum all commentId in this variable? Has anyone had the same case?
const comments = [
{
commentId: 1,
commentContent: 'Hai',
replies: [
{
commentId: 11,
commentContent: 'Hai juga',
replies: [
{
commentId:...
0
votes
3
answers
31
views
Tick Tack Toe: Filter multidimensional array in JavaScript
I am learning to filter nested arrays in javascript and I believe this example can help me to understand it better. below is the object.
const game = () => {
return {
player1: {
...
0
votes
2
answers
30
views
Simplest method to merge two objects using a Lens
I'm new to Ramda and trying to restrict myself to not resorting to vanilla JS methods for tasks like this while I adjust. I'm stuck on something that feels very simple. Ramda loses clarity for me as ...
-1
votes
0
answers
17
views
Suggest Suitable Approach or Design Pattern for fallbacks in code
I have a below problem statement and seek better advice on Suitable Approach or Design Pattern for fallbacks in code
We have 3 database tables and 1 single node redis instance
If redis is down for ...
1
vote
1
answer
25
views
Uncaught TypeError: Cannot read properties of undefined (reading 'length') in my react app
I'm developing a react app but I am facing an uncaught type error. I've followed an online tutorial but I can't fix it. Here's my code:
import React, { useState, useEffect, createRef } from 'react';
...
0
votes
0
answers
27
views
How to compare strings from two arrays of objects, and find duplicate in Javascript
var array1 = [
{
id: 1,
value: 'value',
children: ["string1", "string2","string3"]
},
{
id: 'child2',
value: 'value',
children: ["...
0
votes
1
answer
29
views
Javascript variable undefined outside if else condition [duplicate]
I have 2 objects coming from props and I am assigning these objects to their variable by if else condition
let var1;
let var2;
if (props.id === 1) {
var1 = props;
console.log(var1)...
0
votes
0
answers
16
views
Transfering data from one column to another column [closed]
I want to create four columns and transfer specific cell data of one column to another column of same table on button click using javascript.
1
vote
1
answer
29
views
JavaScript, get one object key name knowing the second [duplicate]
Let's say I have an object that has two key-values:
let object = {name: "abc", id: 12}
But let's say, I don't know one of the key-names, so:
let object = {<unknown_to_me>: "abc&...
0
votes
2
answers
24
views
Trying to return a filter() value from an array of objects based on conditionals
I'm trying to return only a part of my object as an array based on conditionals but I'm kinda stumped.
I have an array of objects and I want to return an array of names for each key : value they fit ...
1
vote
2
answers
29
views
Javascript make object string keys enumerable
I have a class set up with string keys, like this:
class MyClass {
constructor() {
this.id = 0
this.data = []
}
"GET /data"(req, res) {
res.json(this....
0
votes
0
answers
6
views
What is the best way to simplify html content stored in array of objects?
I am trying to get all the data stored in an array of objects displayed dynamically on the same web page when user clicks on links added to a card grid.
Here is what I have coded so far, is there any ...
0
votes
2
answers
28
views
Blackjack Javascript: Remove item in an object or an array
I have completed a Blackjack tutorial, with some issues left unsolved in it (for tutorial purposes maybe).
I am attempting to remove a card object from a collection once that card has been dealt.
Here ...
0
votes
0
answers
9
views
Learning Typescript: object passed into a async function and then renaming one of the props of the object [duplicate]
I have this code I am using in my Javascript version of the application.
Basically I am passing this object
{
email,
password
}
to a async function.
Then the conveniently rename the email property to ...
1
vote
0
answers
22
views
'require.context' is not returning file names
I am working on a NextJS app and have created a few functions that facilitate a user uploading files. Files uploaded by the user will live in the "../public/uploads" directory until my team ...
0
votes
1
answer
33
views
What is a rich object?
I'm learning Express. While doing a tutorial, I stopped to try to figure out why the tutor used express.urlencoded({extended: false}). I learned what url-encoding is, and I've read descriptions on the ...
0
votes
1
answer
24
views
Create a new array of boolean values by comparing two arrays with objects
I have a question about creating JavaScript arrays. Here's what I want to do.
I have two arrays. Each array has object(s) in them.
The first array has exactly 5 objects, each with a key/value pair (id/...
0
votes
1
answer
26
views
Jquery Object and Array implementation
I have an Object
let data = {
a: 1,
b: 2,
c: {
abc: "ak",
bcd: "gh",
cfv: "ht"
}
}
then I have ...
-1
votes
3
answers
58
views
Loop or map array inside the JavaScript object
I have an array of javascript objects like:
const arrayData = [
{ name: "campaign 1", date: "2022-05-13", milestones:[{name:"Planning", targetDate: "2022-05-25"}...
0
votes
1
answer
24
views
How can I 'not allow' the user to retrieve same information from the server multiple times in my 'React' Weather-app?
I'm learning React and as a practice I'm building a weather-app.
My App Photo
Everything is ok. but I want When a User type a City name for example 'London' and click the Search button and get the ...
0
votes
0
answers
21
views
How to fetch key and value from javascript object using Object.entries? [duplicate]
I have tried this but if i do nested loop I cannot able to get the output for that particular nested one
const obj = {
"foo": 'bar',
"baz": 42,
"name": "uday",
"age": 24,
"studies": {
...
0
votes
2
answers
41
views
Filtering objects based on the value of an array of objects
I'm making a note-taking app in React and I have some data that looks like this. I'm wanting to filter it so that only the objects which contain a tag in an array remain, and the rest are removed.
Raw ...
0
votes
0
answers
5
views
Zingchart goal property
is there any way to apply rules for goal property in zing chart? like visible: false if certain condition is met.
'goal': {
'background-color': '#000',
'border-color': '#000',
rules: [
...
2
votes
4
answers
39
views
Looping through array of objects, output created elements to html with javascript
I have created a constructor function and a few objects that are pushed into an array.
From here I need to call a function on these objects in an array which outputs to a basic html front end. I have ...
0
votes
2
answers
29
views
Check if property of object exists within second object
I want to check if a property in a first object exists within a second object and change it's value if it's different, dinamically. The first object properties may change because it's created ...
1
vote
0
answers
33
views
How to make two range price input have space between each other?
hey guys I'm creating a Slider Price input
and I have two ranges one from the left side and the right side, they both are connected to each other
but they touch each other, how I can create limited ...
-1
votes
0
answers
39
views
Best way to implement a library
I have created a library, for the sake of learning, with a few methods in the Global Object, Global Function Object, and the Global Array Object, apart from my own Object created inside the library.
I'...
0
votes
0
answers
46
views
Does jsdom support function fetch when parsing string or loading urls in nested <script> tags?
Probably a very beginner question as I am a just learning. I'm using a windows 10 Nodejs latest distribution as well as a 512 Meg tiny core 32 virtual box distribution.
The ultimate goal is to read ...
1
vote
0
answers
10
views
Getting data attribute from root in ReactJs
I'm trying to grab the attribute listed in the div being rendered but it returns undefined. Any idea on how to go about it will be greatly appreciated
index.html
<body>
<noscript>You ...
0
votes
1
answer
44
views
looping through an array of objects that contains three key, value pairs
I have these objects, which could be in an array, like in the example or a database:
[
{ "payer": "DANNON", "points": 1000, "timestamp": "2020-11-02T14:...
-1
votes
1
answer
45
views
Link between two JavaScript objects and then create condition
I have this set of data :
[
{
CIRPIC: 'SAL',
ALLPIC: [7, 8, 9, 10]
},
{
CIRPIC: 'SUC',
ALLPIC: [5, 6, 7]
},
{
CIRPIC: 'LI3',
ALLPIC: [10, 13]
},
{
CIRPIC: '...
0
votes
2
answers
76
views
Transform JSON into required format
Here is my input JSON
[
{
"date": {
"value": "2022-05-01"
},
"parent": {
"...
-3
votes
1
answer
27
views
Removing Object from Array of Array in Javascript [closed]
Hey Guys I am exporting some data.
And the challenge I am facing is the data should be in Array of Objects but don't know the data format is Array in Array of Objects.
I can write a script to ...
0
votes
2
answers
49
views
How to loop through an object of arrays in Javascript?
For the below code,
const groupbysubject = {
"Mathematics":
[
{totalStudents: "23", average: "78", class: &...
0
votes
1
answer
28
views
How to get common values of multiple nested array of objects
i want to get common values by name not by id, from every view. for eg: here 'view 6' and 'view 2' is common.
-here is my response (allDeviceView):
[
{
"ip": "111.11.11.11&...
0
votes
3
answers
55
views
Loop through array of differently structured JSON objects/arrays
I feel like this is mostly an issue with how I'm looping through the JSON, so am posting that first. This is a series of JSON responses from Promise.allSettled() posted below.
The problem I am having ...
0
votes
0
answers
14
views
How to store a map in a Chrome Extension using storage.sync? [duplicate]
I would like to store some settings for sites individually and my idea was to store a map with the domain names as keys and the settings as value using storage.sync from the Chrome API.
When I try to ...
0
votes
3
answers
43
views
How to access a function defined as key of an object from within another function defined as key of same object in JS
Given below code, I need to reuse functionality from innerFunc1 and innerFunc2 in innerfunc3, but I am not sure, how innerFunc1 and innerFunc2 can be accessed inside innerfunc3, because those are not ...
1
vote
0
answers
25
views
Can I make a Mobx observable with a custom getter?
I have a need for a Mobx observable object which simply returns whichever property is asked of it as a string. For example, myObs.description would simply return the string "description". ...
0
votes
3
answers
47
views
How to read the dynamic objects data present in JSON?
I am obtaining a JSON from another application. I would like to parse that JSON and read the data present in them. The JSON contains some of the user-defined data which are dynamic and the key/value ...
0
votes
1
answer
22
views
How to inherit and overide object in JS
I have a react StyleSheet with objects
const styleSheet = StyleSheet.create({
picture1: {
height: 50,
width: 30,
alighItems: 'center',
}
picture2: {
height: 50,
...
0
votes
4
answers
60
views
how to find certain key by its value into mixed objects array?
const items = [ { 'first': [205, 208, 222] }, { 'second': 205 } ]
I need to find keys by all coincidence into its value/values
example:
find key by id=205, output: 'first', 'second'
find key by id=...
0
votes
0
answers
17
views
why the number 0 change the values of properties in objects of javascript [duplicate]
let person = {
name: 'muhammed',
num: 01234
}
console.log(person.num)
the answer should be 01234 but it is 668 why?
0
votes
4
answers
45
views
How to filter objects that contains object array
could you help with these problem.
I need to filter the items in the array that contains certains activities in their object array. Heres is the code:
let userArray = [{
name: "alonso",
...
0
votes
0
answers
28
views
Javascript Object attribute updated by nested block is lost?
I would like to understand about this particular behaviour of Javascript.
I have an object defined in the parent scope.
In a nested scope, I created a variable which references a particular object ...
-1
votes
0
answers
12
views
Search an array of objects for all entries containing at least a partial string [duplicate]
so I have a API endpoint which returns a large JSON array of objects.
These objects are all essentially {id: 1, name: "Anna", rating: 10} Some of these objects contain variants of Anna like {...
1
vote
0
answers
43
views
TypeError: Cannot assign to read only property '1' of object '
I will start by saying: I know that this question have been asked several times here on the site.
I'm still asking because not all of the errors i found matched mine, and all of them didn't stem from ...
-2
votes
1
answer
22
views
Consecutive destructure statement issue [closed]
I want to remove the user_id field from 2 different objects but get a compile error. what is the correct way ?
const { user_id, ...userLessId } = user
const { user_id, ...zombieLessId } = ...