Really like that function.
$matches = array('12', 'watt');
list($value, $unit) = $matches;
Is there a Javascript equivalent of that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is, in ‘newer’ versions of Javascript: Destructuring assignment – Javascript 1.7. It’s probably only supported in Mozilla-based browsers, and maybe in Rhino.
EDIT:
actually it wouldn’t surprise me if the V8 Javascript library (and thus Chrome) supports this. But don’t count on it eitherNow supported in all modern browsers(except IE, of course).