F
F
fajjet2015-11-01 00:57:16
css
fajjet, 2015-11-01 00:57:16

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

3 answer(s)
V
Vitaly Inchin ☢, 2015-11-01
@fajjet

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.

K
Konstantin Kitmanov, 2015-11-01
@k12th

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.

A
Alexander, 2015-11-01
Madzhugin @Suntechnic

Looking what prefix. If -moz-transform then MozTransform or mozTransform. And if moz-transform then mozTransform. There is no "correct" here. This is the web, everything was broken here before you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question