PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/tests/javascript/javascript-destructuring.js

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
JavaScript | 42 lines | 32 code | 9 blank | 1 comment | 3 complexity | f8e80e852322fb9228f90872cd81fe85 MD5 | raw file
 1// https://developer.mozilla.org/en/New_in_JavaScript_1.7
 2
 3[a, b] = [b, a];
 4
 5function f() {
 6  return [1, 2];
 7}
 8[a, b] = f();
 9
10for (let [name, value] in Iterator(obj)) {
11  print(name);
12  print(value);
13}
14
15for each (let {name: n, family: { father: f } } in people) {
16  print(n);
17  print(f);
18}
19
20var [a, , b] = f();
21[,,,] = f();
22
23function g() {
24  var parsedURL = /^(\w+)\:\/\/([^\/]+)\/(.*)$/.exec(url);
25  if (!parsedURL)
26    return null;
27  var [, protocol, fullhost, fullpath] = parsedURL;
28}
29
30function h(a, [b, c], {foo: d, 'bar': e}) {
31  f();
32  g();
33}
34
35x = function([a, b]) a + b;
36
37({x: x0, y: y0}) = point;
38var {x: x0, y: y0} = point;
39let ({x: x0, y: y0} = point) {
40  print(x0);
41  print(y0);
42}