New issue
Advanced search Search tips

Issue 876367 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Aug 21
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

Default parameter fails when false && = function()

Reported by jbstrater@gmail.com, Aug 21

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0

Steps to reproduce the problem:
1. open this codepen: https://codepen.io/sidewayss/pen/pOvNZw
2. look at the console (if it is not open, open it)
3. note that the first call to def() returns false, not falsy

What is the expected behavior?
It should return falsy.

What went wrong?
When I pass in undefined, the def function executes to create the default parameter value.  When I pass in false, the default parameter processor seems to think false == truthy.

Did this work before? N/A 

Chrome version: Google Chrome	68.0.3440.106 (Official Build) (64-bit) (cohort: Stable) Revision	1c32c539ce0065a41cb79da7bfcd2c71af1afe62-refs/branch-heads/3440@{#794} OS	Windows JavaScript	V8 6.8.275.26 Flash	30.0.0.154 C:\Users\~\AppData\Local\Google\Chrome\User Data\PepperFlash\30.0.0.154\pepflashplayer.dll User Agent	Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36 Command Line	"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --flag-switches-begin --enable-features=NewAudioRenderingMixingStrategy --disable-features=Windows10CustomTitlebar --flag-switches-end Executable Path	C:\Program Files (x86)\Google\Chrome\Application\chrome.exe Profile Path	C:\Users\~\AppData\Local\Google\Chrome\User Data\Default Variations	c134752e-1ece3553 1a0d11d4-ca7d8d80 ebeb14fc-3f4a17df 34a6bf44-ca7d8d80 752a9400-3d47f4f4 bacf97b2-ca7d8d80 241fff6c-1623a499 3095aa95-3f4a17df c27fec31-2d5b6ed9 7c1bc906-f55a7974 47e5d3db-3d47f4f4 125b7f68-25d35d0e 1149accc-3f4a17df 4dc30737-b8a5ea08 a582a1b8-ad75ce17 3042ad4b-ca7d8d80 ebbb4e0a-ca7d8d80 e56c5101-ad2fa222 44827ee5-f23d1dea 8f1e27f-ca7d8d80 de47491b-3f4a17df 9773d3bd-f23d1dea 43f62d3b-28165b59 9e5c75f1-2ad3bd2f f79cb77b-3d47f4f4 4ea303a6-ecbb250e bcc34a89-3f4a17df 7aa46da5-c946b150 2c1d398c-ca7d8d80 6973a1cf-3f4a17df cac0a91c-77662737 58a025e3-36e97b2c 2a32876a-ca7d8d80 ff29b1bd-37ef7e17 da460ac8-3f4a17df 4bc337ce-69465896 9a2f4e5b-ca7d8d80 1354da85-eb933ac9 17507c76-ca7d8d80 494d8760-52325d43 f47ae82a-86f22ee5 3ac60855-486e2a9c f296190c-a0af34c0 4442aae2-6bdfffe7 ed1d377-e1cc0f14 12e17bc5-e1cc0f14 75f0f0a0-d7f6b13c e2b18481-bca011b3 e7e71889-4ad60575 b1ceb06f-d1372334 3a4029d-ca7d8d80 94e68624-803f8fc4 8834fcca-ca7d8d80 Linker	lld-link  Channel: n/a
OS Version: 10.0
Flash Version: Shockwave Flash 30.0 r0

 Issue 2160  is the master issue for Chrome Default Parameters here:
https://bugs.chromium.org/p/v8/issues/detail?id=2160
 
I have updated the codepen to include other literal falsy values, null and zero. Chrome only functions properly when the parameter is set to undefined. null and zero also fail to set the default parameter value correctly.
Now I've updated the codepen to include a simple value setting for the default parameter, and I'm seeing that I might be a bit confused.
It looks like the behavior is consistent not only across values and functions, but that it is the same as Firefox.
So default parameters only work when the parameter value passed in is undefined?
I guess I read the docs wrong.  It must be undefined or empty, which is undefined.
Sorry!
Status: WontFix (was: Unconfirmed)
Closing as per #2. 

Sign in to add a comment