What does a $ in a javascript function name mean?
GWT outputs codes like this:
function com_mycompany_mywebapp_client_CTest_$$ini开发者_开发技巧t__Lcom_mycompany_mywebapp_client_CTest_2V(){
this$static}
What does the $ mean, or is it just another character like an underscore? Would this_static mean the same thing?
Nuthin. It's just a character. Think of it as an S with a stick stuck through it.
The dollar sign was added to be used for machine-generated symbols so they wouldn't collide with manually written symbols. But syntactically it's just like underscore, it doesn't mean anything special.
When people discovered they could use just $() as a function name, they started to use it as a shortcut for document.getElementById() and different people extended it in different directions. Now it is often used in libraries and frameworks like Prototype or jQuery which both use $() functions in their own way (that's why you have to use jQuery.noConflict() to use both Prototype and jQuery in the same page). The dollar sign is often used in front of variable names to remember that it's a jQuery object, like this:
var $links = $('a');
But some people don't like it being used that way - eg. see the Code Conventions for the JavaScript Programming Language by Douglas Crockford.
精彩评论