"use strict";

// Code running in strict mode
"use strict";

function exampleFunction() {
    nonDeclaredVar = 10; // ReferenceError: nonDeclaredVar is not defined
}

exampleFunction();

"use strict"

// Strict mode is enabled from this point onward.
"use strict";

// Strict mode is applied throughout this file.
function myFunction() {
    "use strict";
    
    // Strict mode applies only within this function.
}
<script type="module">
    function myStrictFunction() {
        // Modules run in strict mode by default.
    }
    
    export default myStrictFunction;
</script>
"use strict"

function exampleStrict() {
    strictVar = 10; // ReferenceError: strictVar is not defined
}

exampleStrict();
function exampleNonStrict() {
    nonStrictVar = 20; // No error, implicitly becomes a global variable
}

exampleNonStrict();
console.log(nonStrictVar); // 20

"use strict"

const sealedObject = Object.seal({ prop: 10 });

// Throws a TypeError when assigning new properties in strict mode
sealedObject.newProp = 20; // TypeError: Cannot add property newProp, object is not extensible
const nonStrictSealedObject = Object.seal({ prop: 10 });

// No error; new property is added in non-strict mode
nonStrictSealedObject.newProp = 20;
"use strict"

function strictExample(param1, param1) {
    console.log(param1);
}

strictExample(10, 20); // SyntaxError: Duplicate parameter name not allowed in this context
function nonStrictExample(param1, param1) {
    console.log(param1);
}

nonStrictExample(10, 20);
"use strict"

function strictFunction() {
    return this;
}

console.log(strictFunction()); // undefined
function nonStrictFunction() {
    return this;
}

console.log(nonStrictFunction()); // Global object (window in browsers)
"use strict"

// Without strict mode
var globalVar = 10;

function someFunction(x) {
    y = x * 2; // Potential error: y is implicitly global
    return y;
}

// With strict mode
var globalVar = 10;

function someFunction(x) {
    var y = x * 2; // Explicit variable declaration
    return y;
}