D
D
Denis Bukreev2016-10-10 19:22:24
JavaScript
Denis Bukreev, 2016-10-10 19:22:24

Why put $ in front of the variable?

I dug into someone else's code and found that in classes, in the names of class properties, the developer writes some variables like this:
this.$variable
Why $?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Andrey, 2016-10-10
@denisbookreev

This is how you mark variables that contain a jquery object.

A
Adamos, 2016-10-10
@Adamos

There is such a practice - the buck is placed in front of those variables in which there should be objects.
Just to make it easy to visually distinguish them from other variables.
The language itself does not care, but the programmer sometimes needs to distinguish them.

D
dom1n1k, 2016-10-10
@dom1n1k

It was originally the practice to refer to jQuery objects this way.
But I, for example, also designate ordinary DOM nodes in the same way.

D
denny911, 2016-10-11
@denny911

This is a form of Hungarian notation. This is the symbol that precedes the name of a variable and is used solely to provide you with information about the variable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question