2

I have:

function _(x){
 return document.getElementById(x);
}

I would like to do the same think for getElementByClassName, but aside from "$" are there any other special characters I can use? I was thinking about may å or some accented character, but I don't know if it will work or not.

Is there any downside to doing something like this?

function å(x){
  return document.getElementByClassName(x);
}
4
  • 2
    stackoverflow.com/q/1661197/613130 function names should be the same. Commented Aug 3, 2013 at 21:03
  • @xanatos can you post that as an answer so I can mark it correct? Commented Aug 3, 2013 at 21:06
  • 2
    Should be closed as duplicate IMO. "Is there any downside to doing something like this?" Is a bit subjective I think. Depending on what language you use on your computer, some names might be difficult to type. Commented Aug 3, 2013 at 21:07
  • Just flagged as duplicate. Commented Aug 3, 2013 at 21:09

1 Answer 1

4

In general the name of a function/variable must start with _, $ or a letter (even accented/with other diacritics)

Here they spoke at length of it: What characters are valid for JavaScript variable names?

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, flagged it as duplicate. I'm not a ninja searcher :D

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.