I was using this statement in my code to cache the jquery selector and this was causing an error in the console. The error was "Missing ; before statement"
var $medium-image-holder = $('#image_'+itemID_value);
where itemID_value is a numeric value. This statement is inside a for loop
Out of curiosity and after trying various tricks to overcome this thing, I replaced the hyphen with underscore in the variable name.
var $medium_image_holder = $('#image_'+itemID_value);
Surprisingly this worked.
I want to know whether using hyphens in JavaScript variable names is not permitted. At least, I didn’t know about this. Would be very helpful if someone clarifies.
Your statement
$medium-image-holderis interpreted as$medium - image - holder($medium minus image minus holder).After interpreting this statement as an algebraic expression, you try to set the outcome of it to a value with another statement (
=$('#image_'+itemID_value)), which is not allowed. That is where your error message comes from.