I am quite new to this and just stumbled across this strange thing:
I am using the function requestAnimationFrame
and have to pass an object as an argument. This Question showed me how to pass an argument to the callback function, however when i pass an object, within the function it turns into a (seemingly random) number:
var myObj = {name : "Sanchez", surname: "Pedro"};
console.log("outside", myObj); // shows me the object
console.log("outside", typeof(myObj)); // object
requestAnimationFrame(function(myObj) {
console.log("inside", myObj); // shows me a random number
console.log("inside", typeof(myObj)); // number
// doSomethingToPedro(myObj)
});
My Question now is, (A) how can i properly pass my object to the callback, and (B) why does this happen?