JSBIN - javascript - ES6 declaring a variable using let x=5;

844 Views Asked by At

I am new, I would like to use JSBin for working the console log next to my code would be great!.

let x = 5;
var y = 10; 

console window:

x is undefined

y=10

I would like to use all ES6 in my Javascript. I tried the babel/ES6 but this doesn't work either? What up JSBin??? Sorry for my newbie question.

1

There are 1 best solutions below

1
Mateusz Woźniak On

Just click on JavaScript button at the top of your workspace and change it to ES6 / Babel. That should do the trick. Check my snippet on JS Bin over there.

Basically it should work out of the box, but it all depends on your browser.

If you are trying to print that variable by typing it in the console, then you won't be able to do that because:

let and const declarations define variables that are scoped to the running execution context’s