---
title: "Discussion on \"Union in Typescript\" | Hashnode"
description: "Discussion on \"Union in Typescript\". Union in typescript allows the variable to hold more than one type of value. It is useful when variable can be of various types. It is defined by | operator between types.\n//Simple Union\nlet randomValue:string|number=12;\nrandomValue=\"John Doe\";\n//ran..."
url: "https://hashnode.com/posts/union-in-typescript/669201216e485e62ee77d822"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Union in Typescript](https://krijanprajapati.com.np/union-in-typescript?utm_source=hashnode&utm_medium=feed)

Union in typescript allows the variable to hold more than one type of value. It is useful when variable can be of various types. It is defined by | operator between types. //Simple Union let randomValue:string|number=12; randomValue="John Doe"; //ran...

Jul 13, 2024 · 1 min read · krijanprajapati.com.np  
Read the article

-   [#typescript](https://hashnode.com/tag/typescript)
-   [#union-type](https://hashnode.com/tag/union-type)

## Written by

[Krijan Prajapati](https://hashnode.com/@krijanprajapati)

@krijanprajapati · Kathmandu, Nepal

  
[View profile](https://hashnode.com/@krijanprajapati)

Experienced Frontend Engineer with a demonstrated history of working in the computer software industry for more than 3 years.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
