Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

var has different scope in javascript #3

Open
egonelbre opened this issue Nov 20, 2012 · 1 comment
Open

var has different scope in javascript #3

egonelbre opened this issue Nov 20, 2012 · 1 comment

Comments

@egonelbre
Copy link

Example:

func test() {
    a := 5
    fmt.Println(a)
    for i := 0; i < 1; i += 1 {
        a := 6
        fmt.Println(a)
    }
    fmt.Println(a)
}

Go and js have different results here.

@tredoe
Copy link
Owner

tredoe commented Nov 21, 2012

It is due to shadowing variables in JS. That is on my ToDo list

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants