Here's the standard example:
var x = "bar";
(function() {
console.log(x) // undefined
var x = 42;
})()
But what happens when you have a parameter?
(function(x) {
console.log(x) // "foo"
var x = 42;
})("foo")
Here's the standard example:
var x = "bar";
(function() {
console.log(x) // undefined
var x = 42;
})()
But what happens when you have a parameter?
(function(x) {
console.log(x) // "foo"
var x = 42;
})("foo")