How to declare a empty variable in JS?

const myVariable = '';


const myVariable;
1 Like

The first one isn’t empty and the latter doesn’t make any sense, an undefined constant is not useful.

1 Like

Thanks @ionatan

so, how to declare a empty variable in JS?

1 Like

What do you mean by empty and what do you need it for?
Variables aren’t storage, they can’t be empty just like how they can’t be full - they’re not space. They can refer to something, or not.
You’d declare it without assigning a value. What you won’t want to do however is to have an undefined constant since that will forever remain undefined… due to being constant… that’s useless.


Above the empty object, declare an empty variable that will hold the user’s access token.

I’m trying to do this in ‘Jammming’ project…

1 Like

Riight but you’ve been using mutable variables in loops and such haven’t you? Use that instead of const

1 Like

Ok, thank you @ionatan

1 Like