-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JavaScript: extract variables and constants in destructuring assignment
Close #1112. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
- Loading branch information
Showing
5 changed files
with
185 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--sort=no |
Empty file.
56 changes: 56 additions & 0 deletions
56
Units/parser-javascript.r/js-destructural-binding.d/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Derrived from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment | ||
const [x] = [1]; | ||
const [y, z] = [1, 2, 3, 4, 5]; | ||
let [a=5, b=7] = [1]; | ||
|
||
let [c, , d] = [1, 2, 3]; | ||
let [e, f = 0, , g] = [1, 2, 3, 4]; | ||
|
||
let [,,] = [1, 2, 3]; | ||
let [,] = [1, 2, 3]; | ||
let [] = [1, 2, 3]; | ||
|
||
const [h, i, ...[j, k]] = [1, 2, 3, 4]; | ||
const [l, m, ...[n, o, ...[p, q]]] = [1, 2, 3, 4, 5, 6]; | ||
|
||
const [A, B, ...{ C, D }] = [] | ||
|
||
const user = { | ||
E: 42, | ||
F: true | ||
}; | ||
|
||
const {E, F} = user; | ||
|
||
const {E: G, F: H} = user; | ||
|
||
|
||
const {I = 10, J = 5} = {I: 3}; | ||
|
||
let {a: K = 10, b: L = 5} = {a: 3}; | ||
|
||
let {M, N, ...O} = {M: 10, N: 20, c: 30, d: 40} | ||
|
||
|
||
const metadata = { | ||
title: 'Scratchpad', | ||
translations: [ | ||
{ | ||
locale: 'de', | ||
localization_tags: [], | ||
last_edit: '2014-04-14T08:43:37', | ||
url: '/de/docs/Tools/Scratchpad', | ||
title: 'JavaScript-Umgebung' | ||
} | ||
], | ||
url: '/en-US/docs/Tools/Scratchpad' | ||
}; | ||
|
||
let { | ||
title: englishTitle, // rename | ||
translations: [ | ||
{ | ||
title: localeTitle, // rename | ||
}, | ||
], | ||
} = metadata; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters