Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
-1 votes
1 answer
68 views

MobX State Tree: get a list of references that are using specific identifier

Well, the question is quite straight-forward. Assume we have some model with identifier const ReferableModel = types.model({ id: types.identifier(), }) and an indefinite number of models that can ...
Limbo's user avatar
  • 2,200
0 votes
3 answers
61 views

Would event listeners prevent garbage collecting objects referenced in outer function scopes?

Let's assume I have the following code: (function () { const largeObject = provideSomeLargeObject(); const largeStaticListOfElements = document.querySelectorAll('span'); const ...
Gras Double's user avatar
  • 16.2k
0 votes
1 answer
33 views

How are reference to objects handled in javascript when returning object and modifying them in their original functions

I am trying to create a function that returns an object and a function that reset this object to its initial state. Something like: const create = () => ({ a: "something" }); const setup = ...
Laurent Lemire's user avatar
0 votes
2 answers
76 views

How to compare if two variables reference the same object in javascript

I am new to JavaScript and getting my hands on the spread operator. I understand that it will deep copy the top-level elements of an array or object but shallow copy the nested arrays or objects. I ...
Oc Oc's user avatar
  • 11
-2 votes
1 answer
118 views

How to copy object properties to another object by reference

I want to be able to bundle the properties of multiple objects into another object by reference, such that when I change the properties in the bundle object it mutates the original objects. I'm using ...
Robert M.'s user avatar
  • 602
0 votes
1 answer
44 views

Data structure in JS | Create reference to an object

In my app, I have quizzes with questions. I'm writing a class whose goal is to load and concat quizzes. I have two arrays in my class. The first array contains the quizz meta data : metadata = [ { ...
Fifi's user avatar
  • 3,477
0 votes
1 answer
38 views

Change specific object value after array is flattened with reduce, how to?

I've got an nested array of objects, which could go multiple levels deep. For other purposes I had to flatten the array of objects to 1 level (non-nested) array. How can I update 1 specific object ...
Petervw's user avatar
  • 39
0 votes
0 answers
19 views

Referencing error with a variable when trying to render an EJS file to display a table of information from mySQL database

Very new to everything so might be a silly query but I receive this error when I try to click on a webpage that should show a table of data from my mysql database but I receive this error: ...
Siku's user avatar
  • 1
0 votes
1 answer
39 views

Javascript Set Object Adding

Why this code output of both are different as adding objects in set make compare references? Code 1 let list = [ {a:1,b:1},{a:2,b:3},{a:3,b:1} ] let set = new Set(list); let newList = [{a:1,b:2},{a:...
Sadman Jahin's user avatar
0 votes
0 answers
14 views

why does console.log() show the new value even when I call it before the I update the array? [duplicate]

I have MyObject{internalArray:["ds","sdfs"]} Then I call console.log(MyObject.internalArray) Then I do MyObject.internalArray.push("weird?") I expect output: ["ds&...
Dudus's user avatar
  • 25
0 votes
0 answers
24 views

JS undefined: access primitive value of undefined without property?

I'm learning JavaScript (JS). I came across that undefined (such as from MDN) is a global property that refers to the undefined primitive value. I've seen this, for example, with the behavior of the ...
mishar's user avatar
  • 455
0 votes
2 answers
32 views

JS : What is the best way to clone an array and get an identical result with new references?

I know 10 different ways to clone an Array in Javascript, but none of them works as I want... Let me explain : This is my array : const a = [1, new Date(), false, { date: new Date(), name: "John ...
Simon Trichereau's user avatar
0 votes
0 answers
30 views

Is there a way to create a reference to a variable in JavaScript? [duplicate]

I need a way to pass a variable to a function and then add to that variable inside of the function. Here's an example of what I need: let x = 0; function addTo(num1, num2) { num1 += num2; } addTo(...
Charles Masgalas's user avatar
0 votes
0 answers
39 views

Value stop changing once saved to an array

I have a React App with a localization object and a current language in global state, e.g: const locale = { eng: { test: "English" }, esp: { test: "Spanish" }, ...
aessiq's user avatar
  • 1
0 votes
0 answers
42 views

Object reference as parameter, javascript

I have a function that takes the full-path(a.b.c) to a field in an object and deletes it, i pass the object as a parameter, part of the function is reassigning the object parameter which is a ...
nitesh yadav's user avatar

15 30 50 per page
1
2 3 4 5
56