Dollar Sign Character

Share

What is the Dollar Sign Character?

The dollar sign character ($) is a character of text that has special meaning in some programming languages.

Usage Examples

PHP

In PHP, ALL VARIABLES start with a dollar sign.

$foo = make_foo($bar);

Bash

In Bash, $ is used to use a variable, but not do define it.

foo=bar
echo $foo

Javascript

In Javascript & Typescript, $ isn't part of the language, but it's an alias for jQuery defined when the library is used.

const $p = $('p');
const $also_p = jQuery('p');

The code above works like the modern Javascript built-in document.querySelectorAll.

You may notice that some variables in Javascript start with a dollar sign ($). That doesn't mean anything in the language, it's merely a convention followed by jQuery programmers to prefix the value returned by jQuery with a dollar sign.

Written by Noel Santos.

About the Author

I'm a self-taught Brazilian programmer graduated in IT from a FATEC. In a world of increasingly complex and essential computers, I decided to use my technical expertise in hardware, desktop applications, and web technologies to create an informative resource to make PC's easier to understand.

View Comments