I have to extract defined variable and function names from a js code passed as a text. Example:
$js_code = " var MyVar1 = 'val1'; \n var MyVar2 = 'val2' ; \n function MyFunc() { some code }";
Extracted:
$js_vars = array("MyVar1", "MyVar2");
$js_func = array("MyFunc");