javascript extract object array to variables like php, c# extract object array to variables like php

PHP extract() function uses array keys as variable names and values as variable values. For each element it will create a variable in the current symbol table.
Do we have the same function in C# or JavaScript?

PHP Example, Assign the values “Cat”, “Dog” and “Horse” to the variables $a, $b and $c:

<?php
    $a = "Original";
    $my_array = array("a" => "Cat","b" => "Dog", "c" => "Horse");
    extract($my_array);
    echo "\$a = $a; \$b = $b; \$c = $c";
?> 
Output is: $a = Cat; $b = Dog; $c = Horse 

156 thoughts on “javascript extract object array to variables like php, c# extract object array to variables like php”