Skip to content
Advertisement

Tag: variables

How to listen to external variable changes in React

Hope you’re doing well 🙂 I’ve an “auth.js” file, with an aysnc function to get the userId and then store it in session storage. Here it is: Then I access this variable in all components that need it, in order to make other requests. Example in App.js: The problem is that, in the first render, the userId comes null (obviously)

how do i copy an array correctly

im trying to make a copy of an array but when i change the copy it also changes the original. i have tried using Object.assign([], scenes), scenes.clone() and tried using a for loop Answer You can also try const arrayCopy = JSON.parse(JSON.stringify(initialArray)), although the method using the spread operator should work as well.

Access nested JSON with month numbers

i got an json file with monthly values. i need to access these. I am not able to archive this. Maybe i just make an mistake. How can i get the value from the second “sales” with 9.99? I use JS to get the total_sales. This works. I really need you help for this. For more clearence: The JSON-File is

javascript variable and value concatenation

I have a list of variables: What i would like to do, is insert the value of a given variable from the option options, into an element, but the ‘number’ of the variable (ie, 1, 2 or 3) is itself coming in as a variable, say itemNumber. What I would like to do is: $(element).html(subcatlist+ itemNumber); … Which would give

how to pass csrf_token to javascript file in django?

Here is my javascript code that works fine. but I like to keep javascript files seperate and not use as inline script tags I want to include this in my custom.js file that I have included in my base.html. which is I am not able to reference csrf_token that is available in the current template in Django to the static

Advertisement