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

Arguments object scope not maintained within inner functions when using function shorthand () #10476

Closed
jdalrymple opened this issue Dec 27, 2016 · 2 comments
Labels
invalid Issues and PRs that are invalid.

Comments

@jdalrymple
Copy link

jdalrymple commented Dec 27, 2016

Version: 7.3.0, 6.4.0, 4.0.0 (Just tested these three)
Platform:

  1. Linux 4.8.13-1-ARCH deps: update openssl to 1.0.1j #1 SMP PREEMPT x86_64 GNU/Linux
  2. Also tested in Chrome 55.0.2883.75 (64-bit)
function test(){
  this['fake'] = () =>{
	console.log(arguments)
  }
}

var a = new test('a');

a.fake('dummyArguments')

=> 'a'

Shouldnt this return 'dummyArguments' since the arguments object is scoped https://stackoverflow.com/questions/29216881/inner-function-scope-in-javascript

Where as when not using the function shorthand:

function test(){
  this['fake'] = function() {
	console.log(arguments)
  }
}

var a = new test('a');

a.fake('dummyArguments')

=> 'dummyArguments'

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Dec 27, 2016

An arrow function expression has a shorter syntax than a function expression and does not bind its own this, arguments, super, or new.target.

MDN

@jdalrymple
Copy link
Author

jdalrymple commented Dec 27, 2016 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Issues and PRs that are invalid.
Projects
None yet
Development

No branches or pull requests

4 participants