lundi 9 février 2015

How do I pass a string within an object literal in JS?

I have just learned about code organization with object literals, but I haven't been able to figure out how to pass a string variable within an object literal. This is my code kind of looks like:



var foo = {
onReady : function() {
$( '.adiv' ).click( foo.action( 'test' ) );
}
action : function( x ) {
alert( x );
}
jQuery( function($){
foo.onReady();
});




Aucun commentaire:

Enregistrer un commentaire