diff --git a/101_use_strict/index.html b/101_use_strict/index.html new file mode 100644 index 0000000..35d66da --- /dev/null +++ b/101_use_strict/index.html @@ -0,0 +1,11 @@ + + + + + + use strict + + + + + diff --git a/101_use_strict/script.js b/101_use_strict/script.js new file mode 100644 index 0000000..da1f749 --- /dev/null +++ b/101_use_strict/script.js @@ -0,0 +1,26 @@ +"use strict"; +let a = 45; +console.log(a); + +// 1. demo1 of restriction after using "use strict" +d = 28; // not allowed because strict mode is on. +// Uncaught ReferenceError: d is not defined + + +// 2. demo2 of restriction after using "use strict" +console.log(this); +function tryThis(num) { + console.log(num); + console.log(this); // undefined. bcz in strict mode this can't be used inside function. +} +tryThis(5); +let fun = () => { + console.log(this); // window object +}; +fun(); + + +/** + * Note: + * react uses strict mode by default. + */ \ No newline at end of file diff --git a/102_module.mjs/module1.mjs b/102_module.mjs/module1.mjs new file mode 100644 index 0000000..2f1d21b --- /dev/null +++ b/102_module.mjs/module1.mjs @@ -0,0 +1,11 @@ +const a = "Akash"; +const b = "akki"; +const c = "Shruti"; +const d = "zingur"; +const e = "Disha"; + +export default b; +export {a}; +export {c}; +export {d}; +export {e}; \ No newline at end of file diff --git a/102_module.mjs/package.json b/102_module.mjs/package.json new file mode 100644 index 0000000..77c9e3f --- /dev/null +++ b/102_module.mjs/package.json @@ -0,0 +1,12 @@ +{ + "name": "102_module.mjs", + "version": "1.0.0", + "description": "", + "main": "script.mjs", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC" +} diff --git a/102_module.mjs/script.mjs b/102_module.mjs/script.mjs new file mode 100644 index 0000000..b760543 --- /dev/null +++ b/102_module.mjs/script.mjs @@ -0,0 +1,4 @@ +import name, {a, c} from "./module1.mjs"; +console.log(name); +console.log(a); +console.log(c); \ No newline at end of file