Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does $ mean in pure Javascript [duplicate]

I was watching a video about object literals in JS. Then the guy in the video did something like this:

var Facebook = {
    name: 'Facebook',
    ceo: {
        firstName: "Mark",
        favColor: "Blue"
    },
$stock: 110
};

My question is why is there a $ sign in front of stock? Is there a special meaning? or did he just use it for naming purpose only? I entered $ in console and got something like this: function $(selector, [startNode]) { [Command Line API] }

I understand that $ sign is used as a selector for JS libraries like JQuery, but what is it's significance in pure JS?

like image 869
Mr. T Avatar asked Sep 29 '26 14:09

Mr. T


1 Answers

It's just a character. If you saw something in the console it's because some script loaded by that page assigned it a value and it was still in the global scope.

Sometimes (like with jQuery or Angular) it can get used by convention to denote that the value assigned to that variable or property is related to those libraries somehow.

In your example it's just the name of a property.

like image 116
aaronjkrause Avatar answered Oct 01 '26 05:10

aaronjkrause