Skip to content

Instantly share code, notes, and snippets.

@navanathjadhav
Created June 17, 2022 13:51
Show Gist options
  • Save navanathjadhav/200b78788daeecd43c473e6afd233456 to your computer and use it in GitHub Desktop.
Save navanathjadhav/200b78788daeecd43c473e6afd233456 to your computer and use it in GitHub Desktop.
Example of Avoiding global varibales
"use strict";
/*
* This will not be hoisted as global variable
*/
function Greet() {
message = "Hello & Welcome to Ever Blogs"; // It will throw run time error
}
/*
* This will not become global variable as global functions
* have their own `this` in strict mode
*/
function Greet() {
this.message = "Hello & Welcome to Ever Blogs";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment