Javascript相当于PHP的列表() [英] Javascript equivalent of PHP's list()
本文介绍了Javascript相当于PHP的列表()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
非常喜欢这个功能。
$matches = array('12', 'watt');
list($value, $unit) = $matches;
是否有相当的Javascript?
Is there a Javascript equivalent of that?
推荐答案
但是在Javascript的新版本中:解构分配 - Javascript 1.7 。它可能只在基于Mozilla的浏览器中支持,也许在Rhino中支持。
There is, but in "new" versions of Javascript: Destructuring assignment - Javascript 1.7. It's probably only supported in Mozilla-based browsers, and maybe in Rhino.
var a = 1;
var b = 3;
[a, b] = [b, a];
编辑:实际上,如果V8 Javascript库(以及Chrome)支持这一点,我也不会感到惊讶。但是不要指望它:)
actually it wouldn't surprise me if the V8 Javascript library (and thus Chrome) supports this. But don't count on it either :)
这篇关于Javascript相当于PHP的列表()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文