quickjs icon indicating copy to clipboard operation
quickjs copied to clipboard

delete a?.b does not take effect

Open chemwolf6922 opened this issue 4 years ago • 3 comments

chemwolf6922 avatar Nov 17 '21 04:11 chemwolf6922

test code

let a = {b:true};
delete a?.b;
console.log(JSON.stringify(a));

outputs:

{"b":true}

Run this code with node, and the output will be:

{}

chemwolf6922 avatar Nov 17 '21 04:11 chemwolf6922

The use case for this will be

delete a.b?.c;

where a.b may not exist.

chemwolf6922 avatar Nov 17 '21 04:11 chemwolf6922

This should definitely be fixed. Optional chaining, as part of ECMA2020, must also work for 'delete'.

mstepin avatar May 04 '22 23:05 mstepin

fixed

bellard avatar Jan 09 '24 18:01 bellard