Getting some error if my variable name contains "hiphen" in the name inside javascript.

Not applicable

Hi,

I m having a scenario, where I need to use a variable which is having -"hiphen in its name.

When I am declaring the variable in the js. It is giving me "red cross symbol" at the line number saying

"missing ; before statement"

-----js code ----

var my-Var;

-----js code ----

Could some help me the work around here?

Thank you.

0 1 156
1 REPLY 1

In general JavaScript, variable/function names can't contain -. They can only contain letters, $, and _ (Underscore)

In JS dash/hypen is read as the subtract operator. So it gives an error.