Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Saqib Ishfaq](https://secure.gravatar.com/avatar/07fe610c9a793187e40246744dfc29be?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Saqib Ishfaq
13,912 Pointsif i use let instead of var here , are there any issues i should be aware of?
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if(xhr.readyState === 4){
let employees = JSON.parse(xhr.responseText);
}
};
2 Answers
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsJust be aware that "let" (or "const") has block scope, which means it will only be available inside the conditional block. But if you don't need to access it after the conditional that's a good choice.
And it doesn't apply here, but you should bear in mind that declarations using "var" are hoisted, but those with "let" or "const" are not.
![Teacher Russell](https://uploads.teamtreehouse.com/production/profile-photos/8280332/micro_WIN_20181017_08_19_07_Pro__2_.jpg)
Teacher Russell
16,873 PointsHere's how I did it. https://w.trhou.se/s1hxglfs0b
I would use const instead of let, any time you can. That's just me, and I'm pretty new at all of this. I don't see a reason to use let unless it's really necessary. Of course, I'm a hobbyist, one year in, and I only discovered ES6 very recently. Just a note, I enjoy Dave's courses, and though there's a lot out of date here, it's fun, and Iove to know how we got to where we are now. I recommend taking this course. So much to learn here.
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsIf a value will not be changed, using "const" is the recommended "best practice".