Typescript Objects, Arrays, Tuples & Enums | Basics Tutorial

  Рет қаралды 25,190

Dave Gray

Dave Gray

Күн бұрын

Пікірлер: 115
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
In this Typescript tutorial, we'll learn about TS Arrays, Tuples, Objects & Enums. If you have questions, please join my Discord server where I answer questions and you can chat with other web dev students: discord.gg/neKghyefqh
@ahmad-murery
@ahmad-murery 2 жыл бұрын
2:50 if we want to specify the type and we don't enclose the union type within parentheses like this using: string | number[] instead of (string | number)[] TS will then think it's either a string or array of numbers, In addition to using interfaces to declare custom types, the real power of interfaces (IMHO) comes from implementing it in multiple different classes, after that we can use that interface to declare a param type in a function which now can accept any object implementing specified interface regardless of what its base class looks like a rare but useful use case for enum is when combined with binary values to represent multiple options, here is a quick example for a collection of weapons might be used in game dev enum Weapon { Pistol = 1, Gun = 2, Bomb = 4, Sowrd = 8 } // Collect a few weapons using bitwise OR let myWeapons = Weapon.Gun | Weapon.Pistol console.log(myWeapons) // Check if you have a specific weapon using bitwise AND if(myWeapons & Weapon.Bomb){ console.log('Drop your bomb') } if(myWeapons & Weapon.Gun){ console.log('Shoot the target') } Finally, thanks Dave and thanks to everyone who read so far,
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Great notes and examples Ahmad! 💯
@flowerofash4439
@flowerofash4439 Жыл бұрын
man, telling me to "please give this video a like" really helpful since I always forget to leave a like before hopping to the next video
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Thank you! 🚀
@zuhaibamjad7668
@zuhaibamjad7668 Жыл бұрын
Thanks Mr Gray. I will remember to keep striving for progress over perfection because a little progress everyday will go a long way.
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
💯🚀
@celestinenwachukwu919
@celestinenwachukwu919 Жыл бұрын
Everyday, I’m grateful I started with JAVA
@dansmar_2414
@dansmar_2414 2 жыл бұрын
Absolutely, one of the best channels about programming!
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you for the kind words!
@Duelweb
@Duelweb 2 жыл бұрын
Just popped in quickly (since I am still doing your Javascript course) to give a thumbs up as I will be returning to watch this very excellent course. Man, I just love your teaching style. No BS, nice n' snappy and to the point!
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you for the kind words!
@BirushaNdegeya
@BirushaNdegeya 10 ай бұрын
This video is great for someone who wants to start in Typescript. Thanks
@keunbai1
@keunbai1 2 жыл бұрын
You are the best teacher in coding ever. Thank you always
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're very welcome!
@alexvass
@alexvass 2 жыл бұрын
Thanks
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you for the support, Alex!
@mdsalahuddin46464
@mdsalahuddin46464 Жыл бұрын
Your channel is the great treasure for the passionate learners
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
I appreciate that!
@gabcompany5960
@gabcompany5960 2 жыл бұрын
Amazing Dave , really loved it, I was looking for a series like this to learn ReactJs, I've seen crash course in ur channel but I need step by step tutorial like this . Thanks again and have a nice day
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're very welcome! After the basics, we'll look at TS & React.
@okonkwo.ify18
@okonkwo.ify18 2 жыл бұрын
You refused to answer my questions about remote jobs but I always refer my friends to your channel cos I love your content
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
I don't refuse to answer any questions. Sometimes YT marks comments as spam or makes them hard for me to find. Please join my Discord to insure your questions are seen. Link to Discord invite in the description.
@okonkwo.ify18
@okonkwo.ify18 2 жыл бұрын
@@DaveGrayTeachesCode Oh. Thanks. I was worried cos I asked twice . Am downloading discord now. See you there
@Hferko67
@Hferko67 Жыл бұрын
Very clear explanations that even I as a beginner could understand.😃
@madi4128
@madi4128 Жыл бұрын
I learned many valuable things from your channel, thanks for sharing it
@mohammadrezaakhshabi7587
@mohammadrezaakhshabi7587 2 жыл бұрын
hello dave thank you for great tutorial. i learned many things from you such as redux toolkit full course and react authenthication, i just want to say thank you and i appreciate that. and i dont want watch other TS courses because i feel more comfortable with your courses and your learnings way, So i wait untill you release the new episode
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You are welcome!
@ranjanrnj6864
@ranjanrnj6864 2 жыл бұрын
Great Video again, Thank you Dave
@damianodamian7907
@damianodamian7907 2 жыл бұрын
Brilliant tutorial, I enjoy a lot your teaching style. It was very interesting, thank you very much. I'm sure your channel is going to grow fast
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you very much!
@syedmajid3202
@syedmajid3202 4 күн бұрын
Thanks for tutorial, very helpful!
@pH7Programming
@pH7Programming Жыл бұрын
Great one Dave! Thanks for sharing this 🤗
@zabiremu
@zabiremu Жыл бұрын
Thank you sir for your wonderful tutorial. Thanks from Bangladesh.
@MOJICA7257
@MOJICA7257 2 жыл бұрын
Thanks again Dave!, You are the BEST!
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
My pleasure!
@blueblue9410
@blueblue9410 2 жыл бұрын
This is an amazing tutorial! Thank you so much for this! I'm learning react and ts and this is super helpful. I'm understanding everything. Gonna watch the entire playlist if I have time
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Glad it was helpful!
@AliRaza-nm3eu
@AliRaza-nm3eu 2 жыл бұрын
i learn a new thing from this video ....if we put ? this make that field optional .... sir really appreciated your teaching procedure ,,,, Thanks for providing these series for free
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome!
@piyushmahapatra5402
@piyushmahapatra5402 2 жыл бұрын
Would request you to start using Typescript in next React Project:)
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Great suggestion!
@hosamgnaba3205
@hosamgnaba3205 2 жыл бұрын
Nice video Dave, thank you 😄😄
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Very welcome!
@rahmatyousefi8273
@rahmatyousefi8273 2 жыл бұрын
You explain very well, thank you
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You are welcome!
@abdulrahmanagboolaosho3582
@abdulrahmanagboolaosho3582 2 жыл бұрын
Thanks man
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome!
@sonamohialdin3376
@sonamohialdin3376 2 жыл бұрын
Awesome teaching thank you
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You are very welcome!
@k303k
@k303k Жыл бұрын
Thanks for the video!
@habib4097
@habib4097 2 жыл бұрын
You are great teacher. Please start Next.js series
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you!
@g-ytub
@g-ytub 2 жыл бұрын
Excellent! keep it up Dave :)
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Much appreciated! I'll keep going! 🚀
@j7coder
@j7coder Жыл бұрын
Amazing Dave!
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Thank you!
@johannedwardpolaniagonzale6797
@johannedwardpolaniagonzale6797 2 жыл бұрын
Thanks for sharing your incredible knowledge.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Glad it was helpful!
@TravinskiyVladislav
@TravinskiyVladislav 2 жыл бұрын
Thank you, Dave
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome!
@DiegoBM
@DiegoBM 2 жыл бұрын
Fantastic content Dave! The first video got me completely engaged! This one is also very good but it feels very packed, since you went through a lot of content (although very well explained), but since you're keeping the duration still short you didn't explain some elements, which I don't know if it's intended and this was just an introduction leaving it for the student to dig deeper, or if you'll be revisiting these topics in future videos. In particular I was wondering if you'll be introducing the "const enum" concept later on, since it has some benefits if you want to keep your JavaScript codebase more streamlined.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Although I often receive compliments for how detailed my tutorials are, they would be much, much longer if I attempted to cover everything. I always recommend students dig deeper into the docs as they learn to discover more.
@DiegoBM
@DiegoBM 2 жыл бұрын
@@DaveGrayTeachesCode I apologise, I expressed myself poorly. By packed I meant more like that there was not enough time to cover everything so in-depth as to touch the "const enum" mentioned earlier, more than there was too much content to process. The video was very detailed in what it was explained indeed.
@alseynidiop8650
@alseynidiop8650 2 жыл бұрын
I you do react-typescrpte , if would be perfect, I mean a react project with typescrpt. Thank you. you are doing an amazing job.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you!
@sarmadfaizan2810
@sarmadfaizan2810 2 жыл бұрын
learn alot from you.. can you please start angular after this..
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Glad to hear that! Thanks for the request, but I have no plans for Angular in the near future.
@Odisej1
@Odisej1 2 жыл бұрын
this is some quality staff.
@BrentHarris00
@BrentHarris00 2 жыл бұрын
thank you!
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Welcome!
@martinmendez695
@martinmendez695 Жыл бұрын
This is a great tutorial... you have no Shades Mr Gray.
@aurobindobhuyan2107
@aurobindobhuyan2107 Жыл бұрын
New subscriber ❤
@roman_k89
@roman_k89 2 жыл бұрын
like #153💪 nice video, I`m learning typescript with you) thanks for an awesome job
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome! 💯
@BackToVoid
@BackToVoid 2 жыл бұрын
thank you sir. btw, what's your favorite Van Halen song ?! im a fan too 🙃
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome! Oh so many to like... it might be Drop Dead Legs. Hard to commit to just one! 🎸💯
@MigalYaroslav
@MigalYaroslav 2 жыл бұрын
nice lesson.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you!
@sidkapoor9085
@sidkapoor9085 2 жыл бұрын
Hello sir, I had a quick question. do backend devs mainly work on CRUD apps at the junior level? appreciate everything you do.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Hi Sid - I cannot give one answer for the entire industry. I think this could vary greatly from job to job. Maybe they land a job and get assigned to maintain a legacy project that no one else wants. Maybe they just get assigned small pieces of a larger project. Maybe they do get assigned a CRUD project. So many possibilities.
@raminisrafilli3267
@raminisrafilli3267 2 жыл бұрын
veryy goood
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you!
@soner8780
@soner8780 2 жыл бұрын
Wohhooo 🥳
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
🚀😎
@big-jo89
@big-jo89 2 жыл бұрын
Thank you Dave for this great content I really love this series I just have a question about TS don't know if this is the right place to ask, but I hope you can help me out here, so I have this array : [ { data: [ { id: 1, title: 'manage team', icon: , href: '/team', options: { selected: false, active: false } }, { /* SAME STRUCTURE */ }, ], }, { charts: [ /* SAME STRUCTURE */ ], }, // MAYBE MORE ... ]; and I just don't know how to annotate it properly in TS 😔, really appreciate your help with this one 🙏
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Please join my Discord where it is easier to share code examples and discuss problems like this compared to the YT comments: discord.gg/neKghyefqh
@big-jo89
@big-jo89 2 жыл бұрын
@@DaveGrayTeachesCode Okay nice, joined 👍
@proletar3799
@proletar3799 2 жыл бұрын
try this, ```typescript: type TData = { id: number; title: string; icon : JSX.IntrinsicElements ; //or something href:string; options: { selected: boolean, active: boolean } } interface IData { [keys : string] : TData[] | undefined; } const myData : IData = [ //put ur objets ] ```
@big-jo89
@big-jo89 2 жыл бұрын
@@proletar3799 yeah this almost identical to what I have come up with, but I think your interface is missing [ ] at the end because I need the Data to hold an array of the structure so my solution was like that : type Data = { [key: string | number]: Item[ ] }[ ]; but again I don't think it's the best way to do it but hey it works, thank you
@bryikcode
@bryikcode Жыл бұрын
Hello Dave thank u , when you complete NextJS Course
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
I just follow the content. No specific timeline to complete.
@bryikcode
@bryikcode Жыл бұрын
@@DaveGrayTeachesCode 😇 no rush , thank u
@rjmacalino3186
@rjmacalino3186 2 жыл бұрын
Off topic: What do you think about Next JS? I finish your MERN lesson but as i heard from other videos, React is not SEO friendly so they use Next to solve that. Next 13 is out btw. Hope you can make a crash course.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Yes, many requests for Next.js and I'm glad I have waited. Anything released before a couple of days ago would be obsolete. I'll cover it in the near future.
@DiegoBM
@DiegoBM 2 жыл бұрын
@@DaveGrayTeachesCode fantastic timing then! I presume that your course will be focusing on Next13 (although I seem to remember that some kind-of-major changes might be coming in future versions)
@YL-pl1ek
@YL-pl1ek Жыл бұрын
Awesome!!!!!!!!!!! I do the like to every video and for sure subscribed as well ! Thank you for the excellence go! Now - all of the above in one words :=> yAsssssz !
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
You're welcome!
@hardwired66
@hardwired66 2 жыл бұрын
Next js typescript tailwind maybe good
@hanhtruong4848
@hanhtruong4848 2 жыл бұрын
Next time i think you should try to covert a ReactJS project you had to new ReactTS project.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
A refactor video would be good. Yes, this tutorial series has two new projects.
@emmanueloluwafemi7236
@emmanueloluwafemi7236 2 жыл бұрын
Dave how are you learning all these and releasing videos at once.. You are really trying. Please learn mySQL.. We need react node express sequelize and mySQL. Relational database management system is the best.. I still learn javascript everyday even though I'm very good at javascript.. I'm afraid I won't forget js if I move to typescript or python
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
I've been doing this for years - definitely not learning everything at once! I so know SQL (and variations like MySQL and MS-SQL). You can always search my channel, but here's a link to the one video I have released about SQL: kzbin.info/www/bejne/jXexpaCerLpofrc I will likely do more in the future. 🚀
@emmanueloluwafemi7236
@emmanueloluwafemi7236 2 жыл бұрын
@@DaveGrayTeachesCode please can you integrate it with node js. Use Prisma framework or sequelize with react express and node please. This kind of video is very scarce in youtube
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
@@emmanueloluwafemi7236 thank you for the request!
@olawumisegun5898
@olawumisegun5898 2 жыл бұрын
Hi, is it possible to get the keys of an interface as an array just like we would normally do with object using Object.keys(Person). my end goal is to get ["name", "age", "location"] from interface Person. interface Person { name: string; age: number; location: string; }
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Keep going in this series. I think what you will want is an index signature and there is a video in this series that covers those.
@nikhilraj4098
@nikhilraj4098 Жыл бұрын
Why does this work? let tupleActual: [string, number, boolean] = ["Nikhil", 24, true]; tupleActual.push(444); console.log(tupleActual); Output=> ['Nikhil', 24, true, 444] Why does this work? Why is TypeScript not throwing an error and allowing us to modify the length? I thought it was supposed to not work
@Grishopping
@Grishopping 2 жыл бұрын
SENESEI online gracias .
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Welcome!
@loukhai
@loukhai Жыл бұрын
@jiauyjiauy3777
@jiauyjiauy3777 7 ай бұрын
hwen?
@BrentHarris00
@BrentHarris00 2 жыл бұрын
EVH is active: false, cause he passed away :(
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
He lives on through his music! 🤘🎸💯 But yes, RIP EVH.
@jserr9682
@jserr9682 Жыл бұрын
when I heard typescritp was static type I was Sold on it ......and Also RIP the Greates Guitarist To EVER LIVE Eddie Van Halen!!!!!!!
Typescript Functions | Basics Tutorial for Beginners
32:12
Dave Gray
Рет қаралды 21 М.
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
8 TypeScript Tips To Expand Your Mind (and improve your code)
10:54
TypeScript Classes Tutorial | TS for Beginners Lesson
31:34
Dave Gray
Рет қаралды 22 М.
Typescript - Generics, Index Access Types, Keyof на простом примере
9:01
PurpleSchool | Anton Larichev
Рет қаралды 9 М.
Typescript Generics | Beginners Tutorial with Examples
24:43
Dave Gray
Рет қаралды 19 М.
Learn Closures In 13 Minutes
13:22
Web Dev Simplified
Рет қаралды 74 М.
Programming Is NOT Enough | Add these 7 skills…
13:19
Travis Media
Рет қаралды 427 М.
This Is One Of My Favorite TypeScript Features
5:22
Web Dev Simplified
Рет қаралды 142 М.