M
miken32
In PHP, if a function returns an array it's fairly common to capture
its return values like this:
<?php
list($foo, $bar, $baz) = some_function_that_return_an_array();
?>
In Javascript, would the equivalent (acceptable) code be this?
[foo, bar, baz] = some_function_that_return_an_array();
I usually run my code through JSLint as a quick sanity check, but this
expression makes it die. Clearly it's a parsing bug in JSLint, but I
also wanted to make sure that I wasn't doing something completely off
the wall. Thanks.
its return values like this:
<?php
list($foo, $bar, $baz) = some_function_that_return_an_array();
?>
In Javascript, would the equivalent (acceptable) code be this?
[foo, bar, baz] = some_function_that_return_an_array();
I usually run my code through JSLint as a quick sanity check, but this
expression makes it die. Clearly it's a parsing bug in JSLint, but I
also wanted to make sure that I wasn't doing something completely off
the wall. Thanks.