Question: Recently I discovered that this syntax works in JavaScript (Chrome 53):

```
function foo([param1]) { // Function argument is declared as array and param1 is used as variable? What is the name of this syntax?
  console.log(param1); 
}

foo(['TestParameter1']); // Case 1 - works. Output: TestParameter1
foo('TestParameter1');   // Case 2 - works??? Why? Output: TestParameter1
foo(123);                // Case 3 - does not work - VM860:1 Uncaught TypeError: undefined is not a function(…)

Result => TestParameter1 // this is the result

```

I see that param1 can be used as variable that references item with index 0 in the first argument (declared as array).

My questions are:

1) How is this syntax named (the [param1] part that lets you use param1 as variable)?

2) Why does "Case 2" work? Is there any automatic conversion?

Answer: 
As @Xufox pointed out, this works because of [`destructuring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) ([array destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Array_destructuring), to be more specific). Your second example works because a [string is an array-like object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#Character_access), so you get `T`, which is `param1[0]`. Numbers are not arrays (or even array-like), so the the engine fails to destructure the argument.

If you coerce your number to a string it will work:

```
foo((123).toString()); 

```
Exactly as said by those brilliant folks above. Here's how the computer reads it:

foo('testParamater1') = foo(['testParamater1']);

but...

foo(123) = foo([[1,2,3]);

Unfortunately for your specific use case, not the same. Sorry!