r/webdev • • Oct 01 '17

Modern JavaScript cheatsheet.

https://github.com/mbeaudru/modern-js-cheatsheet
517 Upvotes

28 comments sorted by

View all comments

-1

u/Chewythepig Oct 02 '17

There’s an error in your example explaining variable scopes in functions, sorry to be a critic: imgur link

3

u/barter_ Oct 02 '17

There's no error, and the comments explain what's happening.

1

u/Chewythepig Oct 02 '17

one of the comments is incorrect

1

u/barter_ Oct 02 '17

There's no error, you can check it by running the code yourself on your browser console (F12):

function myFuntion() {
	var myVar = "Nick";
	if (true) {
		var myVar = "John";
		console.log(myVar);
	}
	console.log(myVar);
}
console.log(myVar);

Like so: https://i.imgur.com/2NM62HF.png