I am trying to call a function within a function. Here is the code
var d = function() {
s: function() {
alert('cool');
}
} ();
d.s();
This does not work. What am I doing wrong
I am trying to call a function within a function. Here is the code
var d = function() {
s: function() {
alert('cool');
}
} ();
d.s();
This does not work. What am I doing wrong
Erm... it looks like maybe you're trying to define an Object with a function?
In that case,
var d = {
s: function(){
alert('cool');
}
};
d.s(); //Invokes the function s
Here is another approach using the so-called module pattern:
var d = function() {
return {
s: function() {
alert('cool');
}
};
}();
d.s(); // invokes the function s