Javascript argument in function
<p>I'm having trouble passing an array as an argument of a function:</p>

<pre><code>function test() {
   var array1 = ["1","2"];
   var show = "&lt;p&gt;Show: &lt;a href=# onClick='showArray("+array1+")'&gt;Click to show array&lt;/a&gt;&lt;/p&gt;";
}
</code></pre>

<p>So I need to have an onClick as it is there, but when I pass an array and call the function </p>

<pre><code>function showArray(array) { alert (array.length); } 
</code></pre>

<p>Returns nothing. Why not work?</p>

<p>EDIT:</p>

<pre><code>function test() {
    var array1 = [];
    array1[0] = {
        "type" : 0, 
        "message" : "example", 
        "from" : "path1",
        "count" : 1,
        "isChecked": false
    };
    array1[1] = {
        "type" : 2, 
        "message" : "example", 
        "from" : "path2",
        "count" : 50,
        "isChecked": false
    };

   var show = "&lt;p&gt;Show: &lt;a href=# onClick='showArray(["+array1+"])'&gt;Click to show array&lt;/a&gt;&lt;/p&gt;";
}
</code></pre>
