Skip to content
This repository has been archived by the owner on Aug 22, 2022. It is now read-only.

Arrays passed by reference, instead of by value #56

Closed
Danack opened this issue Sep 27, 2013 · 1 comment
Closed

Arrays passed by reference, instead of by value #56

Danack opened this issue Sep 27, 2013 · 1 comment

Comments

@Danack
Copy link
Owner

Danack commented Sep 27, 2013

$arr=array();
function foo($arr){
    array_push($arr, 4);
}
foo($arr);
var_dump($arr);

will show array(0) {} in PHP, but is converted to Javascript as:

    var arr={};
    function foo (arr){
        array_push($arr, 4);
    }
    foo(arr);
    console.log(arr);

which will show [4].

@Danack
Copy link
Owner Author

Danack commented Oct 1, 2013

This is just going to be a limitation of the converter. There is no sane workaround to this, as you would need to be able to type the variable to an array, which is beyond the scope of the tool.

@Danack Danack closed this as completed Oct 1, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant