0

I wonder if it is possible to declare 'const exch' as empty first since I need that variable to be global for a loop function?

The below does not seem to work?

const exch;
exch = new ccxt.kortux ({ enableRateLimit: true })
Andreas
  • 975
  • 3
  • 12
  • 25
  • 7
    You can't. `const` is a value that is set once declared, and it never can be reassigned thereafter. – Get Off My Lawn Feb 13 '19 at 22:01
  • 3
    [Const in javascript? When to use it and is it necessary](https://stackoverflow.com/q/21237105/215552) – Heretic Monkey Feb 13 '19 at 22:01
  • _The value of a constant cannot change through reassignment, and it can't be redeclared_ – Shidersz Feb 13 '19 at 22:02
  • 4
    @GetOffMyLawn `const` values can change, they just can't get reassigned. – JohanP Feb 13 '19 at 22:02
  • 1
    More to the point, unlike readonly in say C# or Java (which allow deferred assignment in certain contexts), const requires the expression at the declaration site - this is part of the syntax. – user2864740 Feb 13 '19 at 22:03
  • I see, then I understand. Then I need to declare the const as it is in one go. Thank you for pointing that out! – Andreas Feb 13 '19 at 22:04
  • Why not just write the usual `const exch = new ccxt.kortux ({ enableRateLimit: true })`? What do you mean by "*I need that variable to be global for a loop function*", can you show an example? – Bergi Feb 13 '19 at 22:44

0 Answers0