Created
February 7, 2020 08:00
-
-
Save bipon68/3aae0494d161337e5ffdefc5dc98be14 to your computer and use it in GitHub Desktop.
Scope
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function pFunction(){ | |
| let c = 77; | |
| function cFunction(){ | |
| let d = 4; | |
| console.log('Sum value: ', c + d) | |
| } | |
| cFunction(); | |
| } | |
| pFunction(); | |
| // output: Sum value: 81 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## | |
| 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"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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