Data binding keeps application state and the user interface in sync. A render function writes state into the DOM; input, change, or click events write user actions back into state. This two-way flow does not require automatic synchronization or a framework runtime: both directions can be explicit. section 13.2 section 13.2.1
const state = {
count: 0,
};
function render() {
count.value = state.count;
}
increment.addEventListener("click", () => {
state.count += 1;
render();
});
decrement.addEventListener("click", () => {
state.count -= 1;
render();
});
render();
The counter shows the smallest binding: button events change state.count, then render() updates the output. Calling render() once also displays the initial value. section 13.2.1
Start with direct DOM assignments when a small interface needs only a few bindings. Other choices include data-* bindings, template strings, <template> cloning, EventTarget stores, Proxy wrappers, and signals. Each trades some explicitness for ergonomics; a render function, optionally scheduled with queueMicrotask() to batch updates, is enough for many interfaces. Add a store or other abstraction when the state-sharing or update pattern warrants it. section 13.2 section 13.5
For production code, query elements with document.getElementById() or from a known root rather than relying on element IDs becoming global variables. Keep derived values computed from source state instead of maintaining duplicate state. section 13.2.1 section 13.5






