Sunday, May 19, 2024
19
rated 0 times [  24] [ 5]  / answers: 1 / hits: 35953  / 8 Years ago, tue, december 27, 2016, 12:00:00

Is there a faster/more efficient way of declaring multiple variables in react native? Instead of



let foo = 'foo';
let bar = 'bar';
let foobar = 'foobar';


Obviously not problem for three variables, but for bigger sets of variables, is there a better way?


More From » ecmascript-6

 Answers
15

"Faster"? You've determined there's a performance bottleneck here?!


In any case, you can declare multiple variables:


let foo    = 'foo'
, bar = 'bar'
, foobar = 'foobar'
;

But this is simply JS syntax–is this what you are really asking?


If you have a "large" number of related variables the problem may be more systemic, and there are multiple types of refactorings that might help.


Updated: I used to declare variables like this; I don't anymore.


[#59547] Saturday, December 24, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
grayson

Total Points: 36
Total Questions: 113
Total Answers: 95

Location: Tonga
Member since Fri, Aug 21, 2020
4 Years ago
;