简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM