← Back to design patterns map
Design Pattern

Strategy

Swap algorithms at runtime without changing the caller.

behavioral

Visual Diagram

Context
-> strategy.pay()
-> Stripe / PayPal / Razorpay

When To Use

  • ->Payment method selection
  • ->Passport.js auth strategies
  • ->Compression algorithms
  • ->Sorting or pricing algorithms
Used in: Passport strategies, payment strategies, sorting strategies
strategy.js

Live Editor

Loading...

Output

Run code to see output...

Comments

Sign in to leave a comment. Your name and photo come from Google; nothing else is shared.

Loading comments...