Wouldn't it be cool if JavaScript had explicit scope?
Every function would have an extra scope
variable that represents the scope of that function.
Example
function update_scope(s) {
s.name = "Bob"
}
function do_something() {
update_scope(scope)
alert(name) // alerts "Bob"
}
The same thing can be done with an extra variable
function update_scope(s) {
s.name = "Bob" // alerts "Bob"
}
function do_something() {
var scope = {}
update_scope(scope)
alert(scope.name) // alerts "Bob"
}
But explicit scope is makes the syntax nicer.