m0therway m0therway - 1 year ago 109
Javascript Question

JS variable starting with "@"

I've come across someone's old code that has variables identified like: @user_id@, @reference_id@, and so forth. Wikipedia says "In certain JavaScript implementations, the at sign (@) can be used in an identifier..." In what JS implementations does this work? I can't get it to work.

Answer Source

This is totally valid:

var π = Math.PI;

This does not appear to be valid:

var @yourName = "Jamund";

This works though:

var $yourName = "Jamund";

If you're bored and want to learn all of the gory details: http://mathiasbynens.be/notes/javascript-identifiers

As for your specific problem, yeah it's probably either in a comment (JavaDoc uses @ in its comments and sometimes it's style has been used in JS comments) or it was meant to be processed and replaced server-side.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download