An Identifier is an IdentifierName that is not a ReservedWord ( see 7.6.1). There is nothing special in Javascript that allows jQuery to use the single dollar sign as its object name as mentioned above, it's simply just another valid identifier name.Īccording to Ecma International Identifier Names are tokens that are interpreted according to the grammar given in the “Identifiers” section of chapter 5 of the Unicode standard, with some small modifications. This is a convention borrowed from earlier Javascript frameworks like Prototype, and if jQuery is used with other such frameworks, there will be a name clash because they will both use the name $ (jQuery can be configured to use a different name for its global object). There is another common meaning for a dollar sign in an interpreter nowadays: the jQuery object, whose name only consists of a single dollar sign ( $). In PHP, all variable names must have a dollar sign in front of them. It looks like someone just put a dollar sign at the start for fun - perhaps they were a PHP programmer who did it out of habit, or something. In your example, however, this doesn't appear to be the case. In the past, it has often been recommended to start an identifier with a dollar sign only in generated code - that is, code created not by hand but by a code generator. The syntax doesn't really enforce any particular usage of the dollar sign in an identifier, so it's up to you how you wish to use it. Why would you want a dollar sign in an identifier? Thus, $ is a valid function or variable name in Javascript. They are even allowed to start with a dollar sign, or consist only of a dollar sign and nothing else. Unlike many similar languages, identifiers (such as functional and variable names) in Javascript can contain not only letters, numbers and underscores, but can also contain dollar signs. It has no special significance to the interpreter. The dollar sign is treated just like a normal letter or underscore ( _).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |