Skip to content

Tag: variables

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 operato…

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+ itemNum…

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…