Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions 101_use_strict/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>use strict</title>
</head>
<body>
<script src="/101_use_strict/script.js"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions 101_use_strict/script.js
Original file line number Diff line number Diff line change
@@ -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.
*/
11 changes: 11 additions & 0 deletions 102_module.mjs/module1.mjs
Original file line number Diff line number Diff line change
@@ -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};
12 changes: 12 additions & 0 deletions 102_module.mjs/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
4 changes: 4 additions & 0 deletions 102_module.mjs/script.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import name, {a, c} from "./module1.mjs";
console.log(name);
console.log(a);
console.log(c);