kb/data/developer.mozilla.org/en-US/docs/Glossary/Literal-0.md

11 KiB

title chunk source category tags date_saved instance
Literal - Glossary | MDN 1/3 https://developer.mozilla.org/en-US/docs/Glossary/Literal reference web, html, css, javascript, documentation 2026-05-05T05:36:40.730260+00:00 kb-cron

MDN HTML HTML: Markup language

HTML reference

HTML guides

Markup languages

CSS CSS: Styling language

CSS reference

CSS guides

Layout cookbook

JavaScriptJS JavaScript: Scripting language

JS reference

JS guides

Web APIs Web APIs: Programming interfaces

Web API reference

Web API guides

All All web technology

Technologies

Topics

Learn Learn web development

Frontend developer course

Learn HTML

Learn CSS

Learn JavaScript

Tools Discover our tools

About Get to know MDN better

Blog

  1. Glossary
  2. Literal

Literal

Literals represent values in JavaScript. These are fixed values—not variables—that you literally provide in your script.

In this article

Examples

String literals

A string literal is zero or more characters enclosed in double (") or single quotation marks ('). A string must be delimited by quotation marks of the same type (that is, either both single quotation marks, or both double quotation marks). The following are examples of string literals:

Object literals

An object literal is a list of zero or more pairs of property names and associated values of an object, enclosed in curly braces ({}). The following is an example of an object literal. The first element of the car object defines a property, myCar, and assigns to it a new string, "Toyota"; the second element, the getCar property, is immediately assigned the result of invoking the function carTypes('Honda'); the third element, the special property, uses an existing variable (sales).

See also