This question already has answers here:
"Variable" variables in JavaScript
(9 answers)
Closed 2 years ago.
I wan to make a password storing program, and each password is stored into an independant variable, but I'd have to make an infinite number of variables and assign each input value to its corresponding variable.
So is there a way to make Javascript declare the variables by itself and assign it to its corresponding input value?
you can use array which can be collection of multiple values.
There will not be any specific limit of array in terms of length.
If you don't know about array, please have a look here Or you can try array online here.
Hope this helps, please let me know if you are still not clear.
Related
This question already has answers here:
How can I get query string values in JavaScript?
(73 answers)
Closed 4 months ago.
How can I make an html detects this? For example, I have a game in html, can I save the score to url like "example.com/game?score=15", detect this and set score to information in url? Or at least something like that? If you know what it's called, please tell...
I tried to search (cause I don't exactly know what it is) in google and youtube but no answer.
These are what are known as Request Parameters.
This question already has answers here:
Cartesian product of multiple arrays in JavaScript
(35 answers)
How to utilise TypeScript Variadic Tuple Types for a Cartesian Product function?
(2 answers)
Closed 10 months ago.
Hi can anyone please help me. I want to be able to generate all possible combinations of the array but only certain elements will be changing given two possible numbers to choose from. Their position is important too.
For example: let arr = [1,2,3, (4 or 5), (6 or 7), (8 or 9)]
I want to generate
1,2,3,4,6,8
1,2,3,4,6,9
1,2,3,4,7,8
.
.
.
.
This goes on until 1,2,3,5,7,9
I know it is very similar to binary numbers, I just don't know how to go about it and also the array may change in size so it can lead to a lot of options and possible outcomes.
Please. Someone help.
Edit: clarified the combinations I want to generate
This question already has answers here:
How do I split a string with multiple separators in JavaScript?
(25 answers)
Closed 3 years ago.
I have a string "str1+str2-str3*str4".
I want to split it so I get an array
['str1','+','str2','-','str3','*','str4'].
Could someone help provide a solution?
If JS split lets capture groups become elements, then this should work
/([-+*\/])/
if not, I suggest using a regular find all type thing
using this
/([-+*\/]|[^-+*\/]+)/
otherwise, I'll just delete this.
This question already has answers here:
Is reading the `length` property of an array really that expensive an operation in JavaScript?
(6 answers)
Closed 4 years ago.
I'm an front end webdev intern at a small company where I'm making a panel which displays database statistics.
Now I noticed that on my panel which gives the count for how many entries are in a specific array the specific stat always takes a while to load (my other statistics appear nearly instantly).
Now my question is, does array.length actually loop though the whole array to get it's length?
The length is about 17000 and takes about 5 seconds to appear so I'm guessing that's the time it takes to loop through such a big array.
It is implementation dependent. The optimal implementation should know its length, where as the lazy one would iterate to figure this out.
This question already has answers here:
Do DOM tree elements with IDs become global properties?
(5 answers)
What is the difference between getElementById and simply using an element's ID as a variable?
(2 answers)
Closed 5 years ago.
So, I was coding in class when accidentally got to this point, when you set any ID in HTML5 a global variable is created at the same time, which can be used on the script aparently the same way we use getElementById().
for example:
<div id="identifier"></div>
can be accessed in the script like:
identifier.style.whatever
Can anyone explain me why I can't find any information about this? also, why isn't anyone using this when coding? is it bad to use this instead of getElementById?