user1170330 user1170330 - 11 months ago 29
Javascript Question

Work with returned array from function

I'm trying to return an array from a function and work with its results.

When I just want to get its length, I always get a 0:

function myFunc() {
var arr = [];

arr.push("another test");

return arr;

alert(myFunc.length) // expected 2, but got 0

Here is a fiddle.


You need to call it as myfunc().length because you are calling a function.