please can you tell me why this wont work.
If I call s.A why wont the alert show.
var s = {
A: function () { alert("test A"); },
B: function () { alert("test B"); }
};
s.A;
thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try
Ais a function. If you just says.A;all you’re doing is emitting the reference to whatAis, e.g. if I whacks.A;into Chrome’s javaScript console I get the following:Notice how all it did was output the function definition?
Now, if I say `s.A();’ I get what you originally expected – it fires the function: