Skip to content

Destructuring object with rest operator failed when using Number keys #18273

Closed
@riwu

Description

@riwu
const obj = { 1: 'v1', 2: 'v2' };
const key = 1;

const { [String(key)]: a, ...b } = obj;
console.log(a, b); // a is 'v1', b is { 2: 'v2' }

const { [key]: c, ...d } = obj;
console.log(c, d); // c is 'v1', d is { 1: 'v1', 2: 'v2' }

Demo: https://snack.expo.io/@riwu/destructuring-number-key

Works as intended on Chrome browser, but gave the same output as above when using Chrome debugging, which supposedly uses the same V8 engine as Chrome browser?

Environment

Environment:
OS: macOS Sierra 10.12.6
Node: 9.6.1
Yarn: 1.5.1
npm: 5.6.0
Watchman: 4.7.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz => 0.52.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    JavaScriptRan CommandsOne of our bots successfully processed a command.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions