B
B
beginer1232017-07-20 18:52:32
JavaScript
beginer123, 2017-07-20 18:52:32

What is the smartest and best way to designate JS methods and properties?

Hello, what is the best way to write
let's say there is a say hi method
better than sayHi or say_hi?
I understand there is no difference, but how do professionals do it?
And let's say if the word is an abbreviation, then which is more correct
sayFBI (say_FBI) or sayFbi (say_fbi) The

question is interesting in terms of readability and speed of typing code

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Shemil, 2017-07-20
@Shemil

In javascript, it is customary to write camelCase

S
sta-ger, 2017-07-22
@sta-ger

Properties and variables camel cas with a small letter. Classes - with big. If the method returns or sets a value, the name begins with get and set respectively: getValue(), setValue(val)).
Sometimes you can see the name of a class property starting with an underscore: _property - this is how private properties are usually denoted in OOP.
Constants in capital letters with underscores: SOME_CONSTANT_VALUE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question