default parameters are executed with the wrong "this" value

RESOLVED INVALID

Status

()

Core
General
RESOLVED INVALID
4 years ago
4 years ago

People

(Reporter: blindwanderer, Unassigned)

Tracking

32 Branch
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

4 years ago
User Agent: Mozilla/5.0 (Windows NT 5.1; rv:32.0) Gecko/20100101 Firefox/32.0 (Beta/Release)
Build ID: 20140604030202

Steps to reproduce:

function fun(dt = getInnerThis()){
  function getInnerThis(){ return this; } return [this, dt];
}
fun.apply({0:0})


Actual results:

[ {0:0}, Window ]


Expected results:

[{0:0}, {0:0}]
(Reporter)

Comment 1

4 years ago
I'm stupid, ignore please. I forgot that it wasn't going to inhert the value of this.

function fun(dt = getInnerThis()){
  function getInnerThis(){ return this; } return [this, getInnerThis(), dt];
}
fun.apply({0:0})//[{0:0}, window, window]
Status: UNCONFIRMED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.