logo Online Learner
  • Home
  • Learning Paths
  • Development
    Frontend Development Backend Development
  • Study Notes
  • Free Resume Builder
  • About Us
  • Contact Us
  • Login
  • Sign Up
  1. Learning Paths
  2. TypeScript Tutorial
  3. TypeScript Enums

TypeScript Enums

A TypeScript enum is a way to give friendly names to a set of related values. Instead of scattering magic numbers or raw strings through your code, you define them once in an enum and reuse the names. In real projects, this makes status codes, roles, and modes easier to read and safer to change.

This tutorial covers numeric enums, string enums, reverse mapping, const enums, and how to use enums inside functions. You will also see an honest comparison between enums and union of string literals, and a recommendation on when to choose each.

What Is a TypeScript Enum?

A TypeScript enum is a named collection of constant values. You define it with the enum keyword, and each member gets a name and a value. Enums solve the problem of magic values: numbers or strings that appear in many places with no explanation.

Here is a small example:

enum Direction {
  North,
  East,
  South,
  West,
}

console.log(Direction.North);
console.log(Direction.West);

// Output: 0
// Output: 3

By default, the first member gets 0 and each next member increases by one. The names make your code read clearly: Direction.North is easier to understand than 0.

How Do Numeric Enums Work?

A numeric enum stores numbers. You can let TypeScript auto-increment the values, or you can set them yourself. Auto-increment is handy for simple lists. Custom values are useful when the numbers must match an external system, like an API.

enum HttpStatus {
  Ok = 200,
  NotFound = 404,
  ServerError = 500,
}

enum Priority {
  Low,
  Medium,
  High,
}

console.log(HttpStatus.NotFound);
console.log(Priority.High);

// Output: 404
// Output: 2

How it works: In HttpStatus, each member has an explicit value, so no auto-increment happens. In Priority, the first member is 0, the second 1, and the third 2. You can also start auto-increment from a custom point by setting the first value, and the rest follow.

How Do String Enums Work?

A string enum stores string values. Every member must have an explicit string value because there is no auto-increment for strings. String enums are easier to read in logs and JSON because the value is meaningful.

enum OrderStatus {
  Pending = "PENDING",
  Shipped = "SHIPPED",
  Delivered = "DELIVERED",
  Cancelled = "CANCELLED",
}

console.log(OrderStatus.Shipped);

// Output: SHIPPED

How it works: Each member maps a name to a string. The value "SHIPPED" is what appears at runtime, so logs and network responses show a readable word instead of a number. This is the main reason many teams prefer string enums for statuses.

What Is Reverse Mapping in Numeric Enums?

Reverse mapping means you can look up the name of a numeric enum member by its value. Numeric enums generate both name-to-value and value-to-name entries in the compiled JavaScript. String enums do not have this feature.

enum Color {
  Red,
  Green,
  Blue,
}

console.log(Color[1]);

// Output: Green

How it works: The compiled JavaScript object contains both { Red: 0, Green: 1, Blue: 2 } and { 0: "Red", 1: "Green", 2: "Blue" }. So Color[1] returns the string "Green". This is useful for debugging, but it also makes numeric enums slightly larger in output. String enums skip reverse mapping entirely.

What Is a const enum?

A const enum is an enum that the compiler inlines at every usage site and removes from the output. This makes the compiled JavaScript smaller and slightly faster. However, const enums do not work with isolatedModules, a compiler option used by many modern build tools.

const enum Role {
  Admin = "ADMIN",
  Editor = "EDITOR",
  Viewer = "VIEWER",
}

const currentRole = Role.Editor;
console.log(currentRole);

// Output: EDITOR

How it works: The compiler replaces Role.Editor with "EDITOR" directly in the JavaScript output. There is no Role object at runtime. The isolatedModules caveat: when that option is on, each file is compiled separately, so the compiler cannot see the full enum definition. TypeScript then reports an error or warns you to avoid const enums. For beginners, use regular enums unless you have a clear size reason.

How Do You Use Enums in Functions?

Enums pair naturally with functions. You accept an enum member as a parameter and switch on it. TypeScript then checks that every call passes a valid member.

enum OrderStatus {
  Pending = "PENDING",
  Shipped = "SHIPPED",
  Delivered = "DELIVERED",
  Cancelled = "CANCELLED",
}

function describeOrder(status: OrderStatus): string {
  switch (status) {
    case OrderStatus.Pending:
      return "Your order is being prepared.";
    case OrderStatus.Shipped:
      return "Your order is on the way.";
    case OrderStatus.Delivered:
      return "Your order has arrived.";
    case OrderStatus.Cancelled:
      return "Your order was cancelled.";
  }
}

console.log(describeOrder(OrderStatus.Shipped));

// Output: Your order is on the way.

How it works: The parameter status: OrderStatus restricts the argument to a member of the enum. Each case uses the enum member, so a typo like OrderStatus.Shiped would be a compile error. The switch is exhaustive because every enum member is handled, so TypeScript knows the function always returns a string. If you miss a case, the return type becomes string | undefined under strict mode, and you must handle it.

Enum vs Union of String Literals

A union of string literals is an alternative to enums. It looks like "PENDING" | "SHIPPED" | "DELIVERED". The table below compares the two approaches honestly.

Feature Enum Union of String Literals
Runtime object Yes (generated JavaScript) No, types vanish
Reverse mapping Only numeric enums Not applicable
Readability Very high with named members Good, but strings repeat
Bundle size Adds a small object Zero extra runtime code
Interop with JSON Value is the string (string enum) Value is the string
Works with isolatedModules Yes (regular enum) Yes
Refactoring Easy, one place to change Manual string updates

The honest recommendation: for most modern projects, a union of string literals plus a const object is simpler and safer. It has no runtime overhead and works with every build tool. Enums remain a good choice when you want a single named type, when you are working in a codebase that already uses them, or when you need numeric reverse mapping.

type OrderStatusUnion = "PENDING" | "SHIPPED" | "DELIVERED" | "CANCELLED";

function describeOrder(status: OrderStatusUnion): string {
  if (status === "SHIPPED") return "Your order is on the way.";
  return `Status: ${status}`;
}

console.log(describeOrder("SHIPPED"));

// Output: Your order is on the way.

How it works: The union lists the allowed strings directly. TypeScript rejects any other string at the call site. There is no runtime object, so the compiled JavaScript is smaller. The trade-off is that the strings appear in multiple places, so a rename means editing every occurrence. You can learn more patterns in the Literal Types and Type Aliases & Union Types tutorials.

What Does the Compiled JavaScript Look Like?

It helps to see what TypeScript generates for an enum. Here is a numeric enum and the JavaScript output.

enum Size {
  Small,
  Medium,
  Large,
}
// Compiled output
var Size;
(function (Size) {
  Size[Size["Small"] = 0] = "Small";
  Size[Size["Medium"] = 1] = "Medium";
  Size[Size["Large"] = 2] = "Large";
})(Size || (Size = {}));

How it works: The compiler wraps the enum in a function that fills the object with both directions. Size["Small"] = 0 sets the name-to-value entry, and Size[0] = "Small" sets the reverse entry. String enums skip the reverse entries, so their output is shorter.

Common Mistakes and Best Practices

  • Mixing string and numeric members in one enum. TypeScript allows it in some cases but it creates confusing behavior, especially with reverse mapping. Keep an enum all strings or all numbers.
  • Using const enum without checking isolatedModules. Modern bundlers like Vite and esbuild often enable isolatedModules. A const enum can then fail to compile or behave unpredictably. Use a regular enum or a union of literals instead.
  • Assuming numeric enums are safe from out-of-range values. A numeric enum accepts any number at runtime, so describeOrder(99) may compile if the parameter type is the enum. Add a default case or validate the input.
  • Forgetting that string enums have no reverse mapping. OrderStatus["SHIPPED"] works, but OrderStatus["PENDING"] does not return "Pending" as a name. Use a separate map if you need reverse lookups for string enums.
  • Using enums for values that come from an API as plain strings. You then need casts or mapping functions. A union of string literals fits better because the API values are already the type.

Real-World Example: A Payment Flow

This example uses a string enum for payment status in a function, then shows the same logic with a union of string literals for comparison.

enum PaymentStatus {
  Created = "CREATED",
  Authorized = "AUTHORIZED",
  Captured = "CAPTURED",
  Failed = "FAILED",
}

function nextStep(status: PaymentStatus): string {
  switch (status) {
    case PaymentStatus.Created:
      return "Ask the user to authorize.";
    case PaymentStatus.Authorized:
      return "Capture the payment.";
    case PaymentStatus.Captured:
      return "Send the receipt.";
    case PaymentStatus.Failed:
      return "Show the retry screen.";
  }
}

console.log(nextStep(PaymentStatus.Authorized));

// Output: Capture the payment.

How it works, line by line. The PaymentStatus enum uses explicit string values, so logs show "AUTHORIZED" instead of a number. The nextStep function accepts status: PaymentStatus, restricting the argument to the four members. The switch covers every case, so the return type stays string. Calling nextStep(PaymentStatus.Authorized) matches the second case and returns the capture message. If you passed a raw string like nextStep("AUTHORIZED"), the compiler would reject it because a string literal is not assignable to the enum type. This safety is the main reason teams use enums for finite sets of values.

For comparison, here is the same idea as a union:

type PaymentStatusUnion = "CREATED" | "AUTHORIZED" | "CAPTURED" | "FAILED";

function nextStepUnion(status: PaymentStatusUnion): string {
  switch (status) {
    case "CREATED":
      return "Ask the user to authorize.";
    case "AUTHORIZED":
      return "Capture the payment.";
    case "CAPTURED":
      return "Send the receipt.";
    case "FAILED":
      return "Show the retry screen.";
  }
}

console.log(nextStepUnion("AUTHORIZED"));

// Output: Capture the payment.

Both approaches work. The enum gives you a named type and a single place to change values. The union gives you zero runtime code and seamless JSON interop. Choose based on your team's style and your build tooling.

Summary

  • A TypeScript enum names a set of related constant values and removes magic numbers and strings.
  • Numeric enums auto-increment by default and support custom values and reverse mapping.
  • String enums require explicit values, read well in logs, and have no reverse mapping.
  • const enums are inlined at compile time but conflict with isolatedModules.
  • Enums work well as function parameters, and exhaustive switches keep return types safe.
  • A union of string literals is often a simpler, lighter alternative; use enums when a named type or reverse mapping helps.

Now that you can define named value sets, continue to the TypeScript Any, Unknown & Never tutorial to learn how to handle values of uncertain or impossible types.

Frequently Asked Questions

Are TypeScript enums bad practice?

They are not bad practice, but they are no longer the default choice for many teams. Enums add runtime code and can interact poorly with const enum and isolatedModules. A union of string literals is often simpler and lighter. Choose enums when a named type or numeric reverse mapping genuinely helps your code.

What is the difference between a numeric enum and a string enum?

A numeric enum stores numbers and auto-increments if you do not set values. It also supports reverse mapping from value to name. A string enum stores string values that you must write explicitly. String enums read better in logs and JSON, but they do not have reverse mapping.

Can I use const enum with modern bundlers?

You can, but you must check whether isolatedModules is enabled. When it is on, const enum can fail or behave unexpectedly because each file is compiled separately. Vite and esbuild often enable this option. To stay safe, use a regular enum or a union of string literals instead.

How do I convert a string to an enum in TypeScript?

TypeScript does not do this automatically. You can write a lookup object that maps the string to the enum member, or use a type guard function that checks the string against the enum values. Keep the check explicit so invalid strings are rejected at runtime.

Why does my numeric enum accept a number that is not a member?

Because numeric enums are typed as the enum, but at runtime any number is assignable in many contexts. The compiler cannot stop a value that comes from outside, such as an API response. Add a runtime check or a default case in your switch to handle unexpected numbers safely.

Practice Exercises

Exercise 1 (Easy): Create a Numeric Enum

Create a numeric enum called Weekday with seven members starting from Monday. Print the value of Wednesday.

Show solution
enum Weekday {
  Monday,
  Tuesday,
  Wednesday,
  Thursday,
  Friday,
  Saturday,
  Sunday,
}

console.log(Weekday.Wednesday);

// Output: 2

Members auto-increment from 0, so Wednesday is 2. Use a custom starting value if you need different numbers.

Exercise 2 (Easy): Create a String Enum

Create a string enum called TrafficLight with Red, Yellow, and Green. Print the value of Yellow.

Show solution
enum TrafficLight {
  Red = "RED",
  Yellow = "YELLOW",
  Green = "GREEN",
}

console.log(TrafficLight.Yellow);

// Output: YELLOW

String enums require explicit values, and the printed value is the readable string "YELLOW".

Exercise 3 (Medium): Use an Enum in a Function

Write a function describeTrafficLight that accepts a TrafficLight and returns a short instruction string. Handle all three cases.

Show solution
enum TrafficLight {
  Red = "RED",
  Yellow = "YELLOW",
  Green = "GREEN",
}

function describeTrafficLight(light: TrafficLight): string {
  switch (light) {
    case TrafficLight.Red:
      return "Stop.";
    case TrafficLight.Yellow:
      return "Slow down.";
    case TrafficLight.Green:
      return "Go.";
  }
}

console.log(describeTrafficLight(TrafficLight.Green));

// Output: Go.

The parameter type restricts the argument to enum members, and the exhaustive switch keeps the return type as string.

Exercise 4 (Challenge): Convert an Enum to a Union

Take a string enum called OrderStatus with four members. Write an equivalent union of string literals and a function that accepts the union. Show that both compile and produce the same output.

Show solution
enum OrderStatus {
  Pending = "PENDING",
  Shipped = "SHIPPED",
  Delivered = "DELIVERED",
  Cancelled = "CANCELLED",
}

type OrderStatusUnion = "PENDING" | "SHIPPED" | "DELIVERED" | "CANCELLED";

function describeOrder(status: OrderStatusUnion): string {
  if (status === "SHIPPED") return "On the way.";
  return `Status: ${status}`;
}

console.log(describeOrder(OrderStatus.Shipped));
console.log(describeOrder("SHIPPED"));

// Output: On the way.
// Output: On the way.

The string enum value is assignable to the union because its type is the literal "SHIPPED", so both calls work and produce the same output.



Shaikh Abdul Shahid
Written by Shaikh Abdul Shahid

A Full-Stack Developer with experience in PHP, Laravel, JavaScript, and React.
Founder of Online Learner, sharing practical knowledge and programming tutorials.
Building and maintaining real-world web applications since 2017.

GitLab LinkedIn
X
0 likes
Your Feedback

Help us improve by sharing your thoughts.

IT and Digital Marketing
keyboard_arrow_left Previous
Next keyboard_arrow_right
Online Learner Logo

Online Learner helps developers master programming, database concepts, interview preparation, and real-world implementation through structured learning paths.

Quick Links

  • Frontend Development
  • Backend Development
  • Learning Paths
  • Notes
  • Free Resume Builder
  • Portfolio

Company

  • About Us
  • Contact Us
  • Terms & Conditions
  • Disclaimer

© 2023 - 2026 OnlineLearner.in | All Rights Reserved.

logo
  • code Frontend
  • storage Backend
  • live_help Interviews
  • work_outline PHP Frameworks
  • settings Routine Use
  • book Blogs
Frontend
  • HTML Tutorial
    • HTML Introduction
    • HTML Tags
    • HTML Elements
    • HTML Attributes
    • HTML Heading
    • HTML Paragraph
    • HTML Formatting
    • HTML Quotations
    • HTML Comments
    • HTML Styles
    • HTML Color
    • HTML CSS
    • HTML Images
    • HTML Favicon
    • HTML Links
    • HTML DIV
    • HTML Tables
    • HTML Table Size
    • HTML Table Head
    • Table Padding & Spa...
    • Table colspan rowspsn
    • HTML Table Styling
    • HTML Colgroup
    • HTML List
    • HTML Block & Inline
    • HTML Classes
    • HTML Id
    • HTML Iframes
    • HTML Head
    • HTML Layout
    • HTML Semantic Elements
    • HTML Style Guide
    • HTML Forms
    • HTML Form Attribute
    • HTML Form Element
    • HTML input type
    • HTML Computer code
    • HTML Entity
    • HTML Symbol
    • HTML Emojis
    • HTML Charset
    • HTML Input Form Att...
    • HTML URL Encoding
  • CSS Tutorial
    • CSS Introduction
    • CSS Syntax
    • CSS Selector
    • How To Add CSS
    • CSS Comments
    • CSS Colors
    • CSS Background color
    • CSS background-image
    • CSS Borders
    • CSS Margins
    • CSS Height, Width a...
    • CSS Box Model
    • CSS Outline
    • CSS Text
    • CSS Fonts
    • CSS Icon
    • CSS Links
    • CSS Tables
    • CSS Display
    • CSS Maximum Width
    • CSS Position
    • z-index Property
  • JavaScript Tutorial
    • What is JavaScript
    • JS Syntax
    • JS Variables
    • JS Data Types
    • JS Operators
    • JS Control Flow - IF
    • JS Control Flow - S...
    • JS Control Flow - Loop
    • JS Function
    • JS Object Methods
    • JS Anonymous Funct...
    • JS Recursive Function
    • JS Default Parameters
    • JS this Keyword
    • What is an Array in...
    • What are JavaScript...
    • Error Handling in J...
    • DOM Selection in Ja...
    • DOM Traversal in Ja...
    • Manipulating Elemen...
    • Event Handling in J...
    • JavaScript Event Li...
    • JavaScript Event Pr...
    • Form Handling in Ja...
    • Dynamic Styling in ...
    • JavaScript DOM Elem...
    • Window Object in Ja...
    • What is Local Storage?
    • Regular Expressions...
  • Jquery Tutorial
    • What is jQuery?
    • Benefits of using j...
    • Include jQuery
    • Selectors.
    • Methods.
    • The $ symbol and sh...
    • Selecting elements
    • Getting and setting...
    • Adding and removing...
    • Modifying CSS and c...
    • Binding and Unbindi...
    • Common events: clic...
    • Event delegation
    • Using .on() for dyn...
    • Showing and hiding ...
    • Fading elements in ...
    • Sliding elements up...
    • .animate()
    • Understanding AJAX
    • .ajax()
    • .load(), .get(), .p...
    • Handling responses ...
    • Parent
    • Chlid
    • Siblings
    • Filtering Elements
    • Using find
    • Selecting form elem...
    • Getting form values
    • Setting form values
    • Form validation
    • Handling form submi...
    • jQuery plugins
    • Sliders plugins
    • $.each()
    • $.trim()
    • $.extend()
    • Data attributes
    • Debugging jQuery code
  • Bootstrap 4
    • What is Bootstrap
    • Benefits of using
    • Setting up
    • Container
    • Row and Column
    • Grid Classes
    • Breakpoints
    • Offsetting Columns
    • Column Ordering
    • Basic Typography
    • Text Alignment
    • Text colors
    • Backgrounds
    • Display
    • Font Size Utilities
    • Buttons
    • Navs and Navbar
    • Forms
    • Cards
    • Alerts
    • Badges
    • Progress Bars
    • Margin
    • Padding
    • Sizing
    • Flexbox
    • Dropdowns
    • Modals
    • Tooltips
    • Popovers
    • Collapse
    • Carousel
    • Images
    • Tables
    • Jumbotron
    • Media Object
  • Git
    • Understanding Versi...
    • Download and Instal...
    • Git Configure
    • Git Initialize
    • Add Changes to Staging
    • Commit Changes
    • Branching
    • Merging
    • Remote Repository
    • Understanding Git C...
    • Stashing Changes
    • Viewing Commit History
    • Undoing Changes
  • Ajax Tutorial
    • Ajax Fundamentals
    • Ajax Working
    • XMLHttpRequest Fetch
    • Synchronous vs Asyn...
    • Ajax Advantages
    • Ajax Disadvantages
    • $.ajax() method
    • Ajax GET request
    • Ajax POST Request
    • Json Response
    • Ajax Errors
    • Ajax Form
  • React Tutorial
    • What is React? Begi...
    • React Environment S...
    • React Fundamentals:...
    • Functional vs Class...
    • Props in React Expl...
    • State and setState ...
    • React Event Handling
    • React Conditional R...
    • React Lists and Keys
    • Styling in React In...
    • Styling in React Us...
    • Styling in React Us...
    • Tailwind CSS with R...
    • Tailwind vs CSS Mod...
    • React Hooks
    • React useState Hook
    • React useEffect Hook
    • React useRef Hook
    • React useContext Hook
    • React useReducer Hook
    • Custom Hooks in React
    • React Router – In...
    • Installing React Ro...
    • React Router – Ro...
    • React Router – Ne...
    • React Router URL Pa...
    • React Router Protec...
    • React Router Redire...
    • State Management in...
    • Redux State Managem...
    • Redux Toolkit Expla...
    • Redux Toolkit vs Re...
    • Controlled vs Uncon...
    • Handling Form Input...
    • API Integration in ...
    • Axios in React – ...
    • Handling Loading an...
    • Async Await in Java...
    • Displaying API Data...
    • CRUD Operations in ...
    • React Performance O...
    • React Performance O...
  • Tailwind
    • Introduction to Tai...
    • Utility-First CSS E...
    • Tailwind CSS vs Boo...
    • When and Why to Use...
    • Real-World Use Case...
    • Tailwind CSS Instal...
    • Installing Tailwind...
    • Tailwind CSS with V...
    • Setting Up Tailwind...
    • Install Tailwind CS...
    • Tailwind CSS Colors...
    • Tailwind CSS Backgr...
    • Tailwind CSS Paddin...
    • Tailwind CSS Margin...
    • Tailwind CSS Width ...
    • Tailwind CSS Height...
    • Tailwind CSS Border...
    • Tailwind CSS Border...
    • Tailwind CSS Text S...
    • Tailwind CSS Box Sh...
    • Tailwind CSS Opacit...
    • Tailwind CSS Cursor...
    • Tailwind CSS Overfl...
    • Tailwind CSS Font S...
    • Tailwind CSS Font W...
    • Tailwind CSS Text A...
    • Tailwind CSS Line H...
    • Tailwind CSS Letter...
    • Tailwind CSS Text T...
    • How to Use Google F...
    • Flexbox with Tailwi...
    • Justify Content in ...
    • Align Items in Tail...
    • Flex Direction in T...
    • Gap in Tailwind CSS...
    • Flexbox with Tailwi...
    • Grid System in Tail...
    • Grid System in Tail...
    • Responsive Design i...
    • Positioning & Z-Ind...
    • Background Colors i...
    • Background Images i...
    • Gradients in Tailwi...
    • Image Object-Fit in...
    • Image Overlay Effec...
    • Buttons in Tailwind...
    • Hover & Focus State...
    • Buttons and Forms i...
    • Cards and Sections ...
    • Navbar and Footer D...
  • TypeScript Tutorial
    • TypeScript Introduc...
    • TypeScript Installa...
    • First TypeScript Pr...
    • TypeScript Basic Types
    • Type Inference and ...
    • TypeScript Arrays a...
    • TypeScript Enums
    • TypeScript Any, Unk...
    • TypeScript Interfaces
    • Type Aliases and Un...
    • Intersection Types
    • Literal Types
    • Functions in TypeSc...
    • Classes in TypeScript
    • Access Modifiers an...
    • Abstract Classes
    • TypeScript Generics
    • TypeScript Utility ...
Backend
  • PHP Tutorial
    • PHP Introduction
    • PHP Installation
    • PHP Syntax
    • PHP Comments
    • PHP Variable
    • PHP Echo
    • PHP Data Types
    • PHP Strings
    • PHP Constant
    • PHP Maths
    • PHP Number
    • PHP Operators
    • PHP if else & if el...
    • PHP Switch
    • PHP Loops
    • PHP Functions
    • PHP Array
    • PHP OOps
    • PHP Class & Object
    • PHP Constructor
    • PHP Destructor
    • PHP Access Modfiers
    • PHP Inheritance
    • PHP Final Keyword
    • PHP Class Constant
    • PHP Abstract Class
    • PHP Superglobals
    • PHP Regular Expression
    • PHP Interfaces
    • PHP Static Method
    • PHP Static Properties
    • PHP Namespace
    • PHP Iterable
    • PHP Form Introduction
    • PHP Form Validation
    • PHP Complete Form
    • PHP Date and Time
    • PHP Include Files
    • PHP - Files & I/O
    • File Upload
    • PHP Cookies
    • PHP SESSION
    • PHP Filters
    • PHP Callback Functions
    • PHP JSON
    • PHP AND Exceptions
    • PHP Connect database
  • PHP Functions
    • strlen
    • strtoupper
    • strtolower
    • ucfirst
    • ucwords
    • substr
    • str_replace
    • strpos
    • trim in php
    • explode
    • implode
    • count in php
    • array_merge
    • array_push
    • array_pop
    • array_shift
    • array_unshift
    • in_array
    • array_keys
    • array_values
    • array_filter
    • array_map
    • sort
    • asort
    • ksort
    • abs
    • round
    • ceil
    • floor
    • rand
    • mt_rand
    • max
    • min
    • pow
    • sqrt
    • date
    • time
    • strtotime
    • mktime
    • date_diff
    • getdate
    • fopen
    • fread
    • fwrite
    • fclose
    • file_get_contents
    • file_put_contents
    • file_exists
    • unlink
    • filesize
    • is_readable
    • is_writable
    • urlencode
    • urldecode
    • parse_url
    • http_build_query
    • isset
    • empty
    • is_numeric
    • is_array
    • is_string
    • filter_var
    • htmlspecialchars
    • md5
    • sha1
    • password_hash
    • password_verify
    • die
    • exit
    • var_dump
    • print_r
    • include
    • require
    • json_encode
    • json_decode
    • sleep
  • PHP and MySQL Functions
    • mysqli_connect
    • mysqli_select_db
    • mysqli_query
    • mysqli_prepare
    • mysqli_stmt_execute
    • mysqli_multi_query
    • mysqli_fetch_assoc
    • mysqli_fetch_array
    • mysqli_fetch_row
    • mysqli_fetch_object
    • mysqli_num_rows
    • mysqli_real_escape_...
    • mysqli_insert_id
    • mysqli_affected_rows
    • mysqli_error
    • mysqli_close
    • mysqli_commit
    • mysqli_rollback
  • Python Tutorial
    • What is Python?
    • Install Python on W...
    • Install Python on L...
    • Install Python on m...
    • IDE Setup
    • Python syntax
    • Python Comments
    • Python Indentation
    • Python Variables
    • Python Data Types
    • Python Numeric
    • Python Boolean
    • Python String
    • Python List
    • Python Tuple
    • Python Range
    • Python Dictionary
    • Python Arithmetic O...
    • Python Assignment O...
    • Python Comparison O...
    • Python Logical Oper...
    • Python Bitwise Oper...
    • Python if condition
    • Python if else cond...
    • Python For Loop
    • Python While Loop
    • Python break, conti...
  • MYSQL
    • SQL Introduction
    • Syntax
    • Select statement
    • Select Distinct
    • WHERE Clause
    • Order By
    • SQL AND Operator
    • SQL OR Operator
    • SQL NOT Operator
    • SQL LIKE
    • SQL IN
    • SQL BETWEEN
    • SQL INSERT INTO
    • SQL NULL Values
    • SQL UPDATE
    • SQL DELETE
    • SQL TOP, LIMIT, FET...
    • SQL MIN() and MAX()...
    • SQL COUNT() Function
    • SQL SUM()
    • SQL AVG()
    • SQL Aliases
    • SQL JOIN
    • SQL INNER JOIN
    • SQL LEFT JOIN
    • SQL RIGHT JOIN
    • SQL FULL OUTER JOIN
    • SQL Self Join
    • SQL UNION
    • SQL GROUP BY
    • SQL HAVING
    • SQL EXISTS
    • SQL ANY and ALL
    • SQL SELECT INTO
    • SQL INSERT INTO SELECT
    • SQL CASE
    • SQL NULL Functions
    • SQL Stored Procedures
    • SQL Comments
    • SQL Operators
    • SQL CREATE DATABASE
    • SQL DROP DATABASE
    • SQL BACKUP DATABASE
    • SQL CREATE TABLE
    • SQL DROP TABLE
    • SQL ALTER TABLE
    • SQL Constraints
    • SQL NOT NULL
    • SQL UNIQUE Constraint
    • SQL PRIMARY KEY
    • SQL FOREIGN KEY
    • SQL CHECK Constraint
    • SQL CREATE INDEX
    • SQL AUTO INCREMENT
    • SQL Dates
    • SQL Views
    • SQL Injection
    • SQL Hosting
    • SQL Data Types
  • Node Js
    • What is Node.js?
    • Why use Node.js?
    • Installing Node.js
    • First Node.js progr...
    • Event Loop
    • Understanding npm
    • What are Modules?
    • fs (File System)
    • Http Module
    • Path Module
    • Creating custom mod...
    • Exporting and impor...
    • Setting up a basic ...
    • Handling requests a...
    • Serving HTML
    • Serving CSS
    • Serving JavaScript
  • Python MySQL
    • Database Connection
    • Table Creation
    • Insert Query
    • Select Query
    • Update Query
    • Delete Query
    • Where Clause Query
    • Limit Clause Query
    • Join Tables
    • Order By Query
    • Group By Query
    • Aggregate Functions
    • Parameterized Query
  • Java Tutorials
    • Java Introduction
    • Java Installation
    • Java Syntax
    • Java Comments
    • Java Variables
    • Java DataTypes
    • Java Operators
    • Java Conditionals
    • Java Looping
    • Java Arrays
    • Java Methods
    • Java Classes
    • Java Objects
    • Java Constructors
    • Java Inheritance
    • Java Polymorphism
    • Java Encapsulation
    • Java Abstraction
    • Java Exception
    • Java Interfaces
    • Java File Handling
    • Java Threads
    • Java Access Modifiers
    • Java Static Keyword
    • Java Final Keyword
    • Java Nested Class
    • Java Synchronization
  • Docker
    • Introduction to Docker
    • Installing Docker
    • Docker Architecture
    • Docker Images
    • Docker Containers
    • Dockerfile Basics
    • Docker Volumes
    • Docker Networking
    • Docker Compose
    • Docker Hub & Registry
    • Multi-Stage Builds
    • Docker with Nginx
    • Docker with MySQL
    • Docker with PHP & L...
    • Docker Environment ...
    • Docker Logs & Debug...
    • Docker Security Bes...
    • Docker Swarm Basics
    • Docker vs Virtual M...
    • Real World Docker P...
Interviews
  • PHP Interviews
    • What is PHP?
    • What does PHP stand...
    • PHP Advantages
    • Difference between ...
    • Start a PHP script?
    • Commenting in PHP
    • Variable in PHP
    • Different types of ...
    • Different types of ...
    • Array in PHP
    • Difference between ...
    • Retrieve data from ...
    • PHP handle errors
    • Sessions in PHP
    • PHP Cookie
    • What are the main f...
    • What are the differ...
    • What are the differ...
  • Java Interview Questions
    • Java Basics – Wha...
    • What is the differe...
    • What are the OOP co...
    • Why is the main met...
    • What are the differ...
    • What is the differe...
    • What is Method Over...
    • What is the Differe...
    • What is the Constru...
    • What are the Access...
    • What is the this Ke...
    • What is the super K...
    • What is the static ...
    • What is the final K...
    • What is Exception H...
    • What are Checked an...
    • What is the Differe...
    • What are Multithrea...
    • What is the Java Co...
    • What is the Differe...
    • What is the Differe...
    • What is the Differe...
    • What is the Differe...
    • How Does HashMap Wo...
    • What is the Differe...
    • What is the Differe...
    • What is the String ...
    • What is the Differe...
    • What is Garbage Col...
    • What is the Differe...
    • What is a Lambda Ex...
    • What is the Stream ...
    • What are Optional C...
    • What is the Differe...
    • What are the Key Fe...
    • What is the Record ...
  • React Interviews
    • What is React.js
    • Help In Interviews
    • Features of React
    • What is JSX
    • React's Virtual DOM
    • State and Props
    • React handle data b...
    • React Component
    • setState() method.
    • Controlled Components
    • Lifecycle Methods
    • Significance of keys
    • What are the differ...
  • Laravel Interviews
    • What is Laravel?
    • What are the key fe...
    • Explain the concept...
    • What is a controlle...
    • What is Blade templ...
    • How does Eloquent O...
    • Explain the concept...
    • What are middleware...
    • How do you create a...
    • What is CSRF protec...
    • What is the purpose...
    • What is the purpose...
    • Explain the concept...
    • How do you create a...
    • What is the purpose...
    • How do you define r...
    • What are named rout...
    • Explain the use of ...
    • What is the purpose...
    • What are service pr...
  • SQL Interviews
    • What is SQL?
    • What are the differ...
    • What is the differe...
    • What is a primary key?
    • What is a foreign key?
    • What are the differ...
    • What is the differe...
    • What is the use of ...
    • What is the differe...
    • What is an index in...
    • What types of index...
    • What is a subquery?
    • How do you use the ...
    • How can you find th...
    • Explain the use of ...
    • What is a view?
    • What are the limita...
    • Write a query to fe...
    • Write a query to fe...
    • Write a query to co...
    • Write a query to fe...
    • Write a query to fe...
    • Write a query to fi...
    • Write a query to fe...
    • Write a query to re...
    • Write a query to ge...
    • Write a query to ge...
    • Write a query to li...
    • Write a query to fi...
    • Write a query to fi...
    • Write a query to ge...
    • Write a query to fi...
    • Write a query to co...
    • Write a query to fi...
    • Write a query to li...
    • Write a query to fe...
    • Write a query to fi...
    • Write a query to fe...
    • Write a query to ge...
    • Write a query to co...
    • Write a query to fe...
  • JavaScript Interview Questions
    • What Exactly is Jav...
    • What are the data t...
    • What is the differe...
    • JavaScript double e...
    • What is a Closure i...
    • What is Hoisting in...
    • Understanding "this...
    • What Are JavaScript...
    • Null vs Undefined i...
    • How Does JavaScript...
    • What is a Promise i...
    • Async/Await in Java...
    • Event Delegation in...
    • JavaScript Modules ...
    • How to Prevent a Fu...
    • JavaScript Intervie...
    • JavaScript Intervie...
    • What is bind() in J...
    • Event Bubbling vs. ...
    • Deep Copy vs Shallo...
    • What is the new Key...
PHP Frameworks
  • Laravel
    • Laravel Topics
    • Laravel 7 Installation
    • Install laravel 8
    • Laravel 8 Routing
    • Laravel Controllers
    • Views and Blade lar...
    • Database and Eloque...
    • Authentication and ...
    • CSRF Protection
    • Laravel Model
    • Database: Query Bui...
Routine Use
  • Linux
    • How to Delete a Fil...
    • Install lemp in ubu...
    • How to check packag...
    • Navigating the File...
    • Managing Files and ...
    • Viewing and Editing...
    • Managing Processes ...
    • Scheduling Tasks wi...
    • Disk Usage Analysis...
    • File and Directory ...
Blogs
  • Blogs
    • Free Hosting on AWS...
    • What is SEO?
    • Zoho Free Mail
    • Speed Up Your Appli...
    • What is a JavaScrip...
    • Laravel vs Lumen: T...
    • MySQL vs PostgreSQL...
    • Automate Free MySQL...
    • How to Use Google A...
    • What is n8n?
    • Cloud Platform Comp...
    • Top Common Mistakes...
    • PHP 8.5: The Pipeli...
    • Google Antigravity ...
    • How to Optimize Que...
    • React vs Angular vs...
    • Base44: Features, P...
    • Difference Between ...
    • HTTP Status Codes E...
    • Build Native Mobile...
    • Top 10 JavaScript F...
    • JIRA, Waterfall, an...
    • WebSockets in Moder...
    • A Complete Real-Wor...
    • Why Developers Shou...
    • Service-Based Compa...
    • Bootstrap vs Tailwi...
    • Direct Prompt vs St...
    • Top 25 SEO HTML Tag...
    • Docker Commands Che...
    • Authentication vs A...
    • Top AI Portals in 2...
    • What is Replit? Com...
    • Laravel 13 Released...
    • NEET Paper Leak Pre...