Linked Questions

-2 votes
3 answers
347 views

If you have a JavaScript function that returns two values, is it possible to assign those values to two variables in a single statement? For example, in Python it might look like: (var1, var2) = ...
0 votes
0 answers
39 views

In python you can do: goat, cabbage, wolf, farmer = puzzle.passengers where array is a list of some type. Is there a quick way to do the samething in typescript? I tried: var goat: Passenger, ...
Foobar's user avatar
  • 8,669
78 votes
4 answers
105k views

I’d like to know if standard JS provides a way of splitting a string straight into a set of variables during their initial declaration. For example in Perl I would use: my ($a, $b, $c) = split '-', $...
nb5's user avatar
  • 783
39 votes
3 answers
22k views

I have the following string output_string = "[10, 10, [1,2,3,4,5], [10,20,30,40,50]]" Then I JSON.parse it my_args = JSON.parse(output_string) How do I unpack it in a Python-like way so that every ...
Kit's user avatar
  • 31.7k
5 votes
3 answers
1k views

In some projects that I work, was added some blocks with this syntax: var [code, name] = input.split("/"); console.log(code); console.log(name); I really like this, is so simple and small. It's true ...
0 votes
2 answers
753 views

I'd like to make a custom order form for my website which will allow customers to input a custom engraved message into a textarea. Customers can engrave a maximum of 3 lines. I'd like to collect the ...
0 votes
1 answer
260 views

My code has a variable that contains the multiple value something like: var GlobalOpportunityTypeID="8|9|10" I want to split this value into different variables as per my requirement. How can I do ...
amit Verma's user avatar
0 votes
2 answers
118 views

I have around 30 values stored as variables: var a = 1, b = 2, c = 3, ... z = 26, aa = 27, ab = 28; that I want to scale. I do so using an array: array = [a, b, c]; var ...
0 votes
3 answers
126 views

I got 7 variables (seconds), I am using them to show countdown. All of them counting down simultaneously at the same page. I want to set them to '59' after they reached to '0'. Here is my code : s--; ...
ctarimli's user avatar
  • 322
0 votes
1 answer
57 views

How do I split an array into individual array: [1,2,3,4,5] => [1][2][3][4][5] The array of objects is gotten from a backend API const arr = [ { id: '1', name: 'Emmanuel', ... }, { ...
Peoray's user avatar
  • 1,935
0 votes
2 answers
54 views

I'm using the code below to get access to variables in variables.js from main.js: variables.js: export default { bla: 123, } main.js: var vars = require('./variables').default; class MyClass ...
Adrin's user avatar
  • 615
-1 votes
1 answer
62 views

i wanna understand those results, why [key, value] work that way ? i dont understand how [key, value] return different in both code bellow since both are ECMA 6 let iterable = new Map([['a', 1], ['b',...
Rhag's user avatar
  • 13
0 votes
0 answers
61 views

Array destructuring is super useful: var [a, b, c] = [1, 2, 8]; It looks like it was implemented into Javascript 1.7, but then removed with bug 1083498. Now according to this table it's not supported ...