In JavaScript, literals are fixed values written directly into the code. Unlike variables or complex expressions, literals offer an explicit and concrete value, making coding more straightforward and manageable. 

You can use different literals to represent various data types in JavaScript. They offer a simple and direct way to express data without needing to perform intricate calculations or external requests. 

Here are a few examples of JavaScript literals: 

  • Array literals — A collection of values, each of which is an array element, contained within square brackets. For example, var colors = [“Red”, “Blue”, “Green”, “Yellow”]
  • Boolean literals True and false values
  • Floating point literals — Decimals, fractions, and exponents
  • Integer literals Positive or negative numbers with at least one digit from 0–9, excluding spaces or commas
  • Object literals — A collection of zero or more {name:value} pairs, enclosed in curly brackets
  • String literals — A sequence of characters enclosed in double or single quotes, like “webflow,” “12345,” and “an example of a string literal”

Learn more about Javascript and how using it can add new functionality to your Webflow site.

Other glossary terms

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Hmm…we couldn’t find any results. Try a different search term or reset the filter.
Reset the filter
Load more