This is the most confusing thing ever. The title probably doesn't make much sense. I did my best. Hope I can be clear. Ok i am looking at the tic-tac-toe example from google channel api.
in the javascript portion.
they have something like this;
sendMessage = function(param) {
alert(param);
//this part actually sends message to server,
//for simplicity lets assume it pops up alert.
}
init = function(){
var input = 3;
var submitButton = document.getElementById('submitButton');
submitButton.onclick = new Function('sendMessage(' + input + ')');
}
setTimeout(init, 100);
this pops up an alert and prints 3. I am not sure how this works. But it works. If one can explain that, that would be great too. I could not find anywhere else use of new Function() like this.
The problem is, if the input is a string,
var input = "test";
this does not work, and there is no alert that pops up.
thanks for any explanation and help.
Function()~~eval()