Union Types in TS

preview_player
Показать описание
Welcome to a youtube channel dedicated to programming and coding related tutorials. We talk about tech, write code, discuss about cloud and devops. That’s what we do all day, all year. We roll out a lot of series and videos on our channel.

All the learning resources such as code files, documentations, articles and community discussions are available on our website:

You can find our discord link, github link etc on the above website.

Рекомендации по теме
Комментарии
Автор

Are you aware of new batch of full stack javascript bootcamp ?

HiteshCodeLab
Автор

I have been an angular developer and worked with TS from the past 5 years, still there were a few things to take away from this video. Great work Hitesh

tushar
Автор

your TS videos make me powerful day by day☺

kiranpoojary
Автор

You are doing great Job but please please please complete this Typescript series and provide us all the topics available in Typescript, please do not stop this Typescript series after some videos 🙏🙏

mohitjain
Автор

Summary:
Union type allows a variable to hold one of several specified types. It’s denoted by using the vertical bar (' | ') between types. This is useful when you want to allow multiple types for a single value, while still maintaining some level of type safety.

Syntax: let value: string | number;

nobody
Автор

Another great explanation almost impossible to find somewhere else

sagar-ttub
Автор

I'm like the video before watching because i know that its good video and helpful

HARSHKUMAR-gdu
Автор

Wow this video have so much of knowledge 😍 Learning typescript will pay later

ShubhamVsCode
Автор

Thank you sir for providing such a quality content

LaveshGarg
Автор

There are two types of data types we can mention for any variable, either lowercase (number) or uppercase(Number).
Mostly we will use lower case one,
So why can't we go for upper case?

vivekjaiswal
Автор

Sir in the last.. I guess we can use Enum Type for strict checking

ankushthakur
Автор

what if we do this -

function getDBId(id: number | string) {
// console.log(`db id is ${id}`);
if (typeof id === "string") {
id.toLowerCase();
} else {
id = id.toString();
id += 1;
}
}

when we are converting id to string in the else block it still allows us to add 1 to it in the next loc
ideally we should not be able to do that, we can't add number to a string

How can we avoid that? Or is it a flaw ?

tamoghnadey
Автор

type User= {
username:string;
role:string;
}

type Admin = {
role:string;
sudo:boolean;
}


let uncleBob : User | Admin = { username: 'uncle', role:'user', sudo:false}
console.log(uncleBob)

In this case, instead of User or Admin, it has combined both types of data into one. Is this a problem?

Userkazt
Автор

never add 70% are not subscribing video during the the video it breaks the focus

greenshaheen
Автор

আপনারা যারা একেবারে নতুন শুদু মাত্র তাদের জন্য সহজ ভাবে (graphic design )
সবাই কে ঘুরে আসার দাওয়াত রইল। name: Graphics Robiul.
আশা করি অনেক ভালো কিছু শিখতে পারবেন।

robiul