Course contentsShow
← JavaScript
Lesson 2426 of 2,72349. Common Patterns and IdiomsFree lesson

State and Transition Vocabulary

Understand the core terminology: states, events, transitions, actions, and the current state.

State and Transition Vocabulary

What you'll learn: The essential terms that form the foundation of every finite-state machine discussion.

Core Terminology

When working with finite-state machines (FSMs), you need to speak the language. These five terms are the building blocks:

States

A state represents a distinct condition or mode your system can be in at any given moment. Think of a traffic light: it has three states — red, yellow, and green. Your system is always in exactly one state at a time.

Events

An event is a trigger or signal that may cause a state change. Events are the inputs to your state machine. For the traffic light: a timer event might trigger a transition from green to yellow.

Transitions

A transition is the rule that defines moving from one state to another in response to an event. It answers: "If I'm in state A and event X happens, which state do I go to?" Not every event causes a transition — some events are ignored in certain states.

Actions

Actions are side effects that occur during a transition or while in a particular state. For example, when transitioning from red to green, you might execute an action like turnOnGreenLight(). Actions are the "do something" part of state machines.

Current State

The current state (or simply "state") is the single active state your machine is in right now. It's the runtime value that determines how your system behaves when it receives the next event.

The Flow

Events trigger transitions between states, and transitions can execute actions. The current state always reflects where you are in this flow.

Key Takeaway: States define where you are, events define what happens, transitions define how you move, actions define what you do, and current state tracks your position now.