The code quoted in your question looks like it was written by someone who isn't particularly proficient with JavaScript, since it unnecessarily creates String objects. If it exists at all, it should simply be:
var IMG = 'img';
var DOT = '.';
var CLASS = 'class';
or in ES2015+
const IMG = 'img';
const DOT = '.';
const CLASS = 'class';
As for the "why do this," the best justification I can come up with is that it allows you to find all of the places you've used IMG for the purposes of the img tag without also finding places you've used 'img' for something else entirely.
What it isn't is future-proofing (or at least one hopes it's not meant to be). If you later changed IMG to be 'image' without changing its name, that would be actively misleading subsequent authors working in the code.