Im trying to append the value I get in console log, to an array, but I keep getting undefined. I think the function is asynchronous thats why when i try to access it's undefined at time of execution. From what I understand from documentation is that its function parameters is a callback parameter, can someone tell me how to use the value I get to append to an array or a dict.
var theparam = new ROSLIB.Param({
ros : ros,
name : formid.elements[i].name
});
theparam.get(function(value) {
console.log(value)
});
link to documentation here
you can just add the value from the callback function to your array, when the function is invoked. May look so:
Edit: Ah that's because the console-log is processed before the actual .push is done (unsynchronized). Try to put the further processing code into the callback function like:
Edit with async loop:
}
And you can use it like: