How to change the s variable using IIFE.n() because now it doesn't work. After I execute IIFE.n() IIFE.s still returns "string"
I've tried with this but I rather use let/const and don't want to pass this variable to global scope I want to keep it in module.
const iife = (() => {
let s = "string";
const n = () => {
s = 1e3;
};
return {
s: s,
n: n
};
})()
Currently when I do iife.n() it doesn't change the s variable (when I added return before s = 1e3 it returns 1000 but iife.s still returns "string")
s
, but there'ss
the local variable in the closure and alsos
the property of the returned object. They're two different things. – Caro