Answer the question
In order to leave comments, you need to log in
What is the logic behind prefixes in javascript?
I can not find normal information on prefixes in js. Everywhere everything is in disarray. So explain the same, is the same logic for prefixing everywhere. I often see MozTransform and mozTransform. Can you tell me which is correct or is it different for different browsers? LIBRARY ADVISERS through the forest. EXACTLY IN JAVASCRIPT. I DO NOT NEED TO PREFIX css. <- Notes for the especially attentive. Tell me people who know please.
Answer the question
In order to leave comments, you need to log in
The logic is very simple. In javascript, names cannot contain anything other than _ , letters and $ . It so happened that things that in the “normal nature” we write through a dash (it’s also a hyphen, a dash and a minus) (some CSS properties, HTML attributes), here you need to write according to the rule -ab-cd
= AbCd
, that is, discard the dash, and the letter, following it, raise to upper case. border-width
- borderWidth
, -moz-transform
- MozTransform
, data-tag-for-title
- dataset.tagForTitle
.
The logic is simple: in JS, only classes (Object, Date) and namespaces (more precisely, static classes) (Math) are written with a capital letter (PascalCase). Everything else - with a small (camelCase). Well, the constants are completely in uppercase.
So look to see what you're interested in.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question