Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

関数の仮引数を同じ名前で複数定義できてしまう #860

Open
takejohn opened this issue Nov 21, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@takejohn
Copy link
Contributor

関数の仮引数を同じ名前で複数定義しても文法エラーにならず、実行してもエラーが発生しない

@f(a, a) {
    a
}

<: f(1, 2) // => 1
@takejohn takejohn added the bug Something isn't working label Nov 21, 2024
@takejohn
Copy link
Contributor Author

takejohn commented Nov 21, 2024

JavaScriptではstrictモードでないときに仮引数名を重複することができて、後のほうの引数を参照できるらしい

function f(a, a) {
    return a;
}

console.log(f(1, 2)); // => 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant