I am having two array
var values[];
var labels[];
How can i return these two variables and get from outsied the function.
You can return them in an object literal:
function yourFunction() {
var values = [];
var labels = [];
//code that modifies `values` and `labels`
return { values : values, labels : labels };
}
var a = yourFunction(); //`a.values` is `values` from the function and `a.labels` is `labels` from the function
Return an object or array containing these two variables.
return [
values[],
labels[]
];
A function can return one value/object/array at a time. Now you can do it in smarter way. Use nested Array here.
Put both array inside another array and return that array
var newAr = {};
newArr.push(values)
newArr.push(labels)
return newArr
There are many other ways to create jQuery Array. Refer jQuery Arrays for that.