QL
QUDDUS
2026-03-05T18:02:49Z

JSX — A Formal View (JavaScript + XML Syntax Extension)

JSX — A Formal View (JavaScript + XML Syntax Extension)

JSX (JavaScript XML) is a syntax extension for JavaScript that allows developers to describe UI...

JSX (JavaScript XML) is a syntax extension for JavaScript that allows developers to describe UI structures using a markup-like syntax embedded directly in JavaScript code.

At a conceptual level, JSX is not HTML and it is not executed by browsers directly. Instead, it acts as a declarative representation of a UI tree which is later transformed into standard JavaScript function calls during compilation.

Compilation Model

A JSX expression such as:

const element = <h1>Hello World</h1>;

is transformed by a compiler (e.g., Babel) into:

const element = React.createElement("h1", null, "Hello World");

or in modern React runtimes:

jsx

import { jsx } from "react/jsx-runtime";
const element = jsx("h1", { children: "Hello World" });

Why it is called JavaScript + XML

The name originates from two characteristics:

  1. JavaScript Integration

    • JSX exists inside JavaScript.
    • Any JavaScript expression can be embedded using "{}".

    jsx

    const name = "Quddus";
    

const element = <h1>Hello {name}</h1>;

text


2. XML-like Structure
   
   - JSX uses XML-style syntax rules such as:
   - Nested elements
   - Explicit closing tags
   - Attribute-based element configuration
   ```jsx
   <div className="container">
  <h1>Title</h1>
   </div>

Functional Role in React

From a theoretical perspective, JSX serves as a domain-specific language (DSL) for defining a virtual DOM tree. During rendering, React interprets the resulting JavaScript objects to construct and reconcile the Virtual DOM, enabling efficient UI updates through a diffing algorithm.

So,

JSX can therefore be understood as: