Skip to content

Instantly share code, notes, and snippets.

@bipon68
Created February 7, 2020 08:00
Show Gist options
  • Select an option

  • Save bipon68/3aae0494d161337e5ffdefc5dc98be14 to your computer and use it in GitHub Desktop.

Select an option

Save bipon68/3aae0494d161337e5ffdefc5dc98be14 to your computer and use it in GitHub Desktop.
Scope
let customGlobalVar = "Miew Global Variable";
function miewGlobalScope(){
console.log('Inside a Function: ' + customGlobalVar);
}
miewGlobalScope();
console.log('Outside Function: ' + customGlobalVar);
// output: Inside a Function: Miew Global Variable
// output: Outside Function:: Miew Global Variable
##
let car = {
name: 'Toyota',
price: '20.19 Lakh'
}
console.log(car)
//output: {name: "Toyota", price: "20.19 Lakh"}
function pFunction(){
let c = 77;
function cFunction(){
let d = 4;
console.log('Sum value: ', c + d)
}
cFunction();
}
pFunction();
// output: Sum value: 81
##
function myLocalScope(){
let localScope = "Hey miew ami local scope";
console.log(localScope)
}
myLocalScope();
// output: Hey miew ami local scope
##
function miewObjectFunction(){
let car = {
name: 'Toyota',
price: '20.19 Lakh'
}
console.log(car)
}
miewObjectFunction()
//output: {name: "Toyota", price: "20.19 Lakh"}
function miewFunc(){
console.log('Miew Global Function');
function miewLocalFunc(){
console.log('Miew Local Function')
}
miewLocalFunc();
}
miewFunc();
// output: Miew Global Function
// output: Miew Local Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment