A beginners guide to Typescript | Collective Literal Types, Widening and Narrowing Types
Vložit
- čas přidán 1. 06. 2024
- Check out my Web Development Courses 🔥
developedbyed.com/
🛴 Follow me on:
Twitch: / developedbyed
Twitter: / developedbyed
Instagram: / developedbyed
Github: github.com/developedbyed/
🔥Dope Tracks
Mac Kay - Shade chll.to/00509844
Boukas - Melvin chll.to/10d340df
less.people - Lamp Glow chll.to/51b47e4a
Enough Cereals - Suave chll.to/3ce6c324 - Věda a technologie
Hope you enjoy this series, leave anything you want me to discuss that's typescript related here, so I can talk about them in the next episode 👍
Fullstack course is halfway filmed as well, it's gonna be huge
developedbyed, This video is fantastic! I liked it a lot!
Thank you very much!
8:15 So are we supposed to use only instanceof instead of typeof or are there any cases where we should use typeof?
Hope this makes it clear typeof expression is the operator that lets you determine the type of expression. typeof evaluates to one of the values: 'string', 'number', 'boolean', 'symbol', 'undefined', 'object', 'function'.
typeof null evaluates to 'object', thus the correct way to use typeof to detect an object is typeof object === 'object' && object !== null.
instanceof operator let's identify the instance's constructor. object instanceof Constructor evaluates to true if object is an instance of Constructor.
Usually use typeof for primitives, cause when you pass it an object, array, null or ehatever it will just give you back “object”
Whereas with instanceof you can check if you pass an array for ex
unction isArray(value) {
return value instanceof Array;
}
isArray([1, 2, 3]); // => true
isArray({ prop: 'Val' }); // => false
I would like to buy your Next JS course but is it getting updated?
Update out in about 2 weeks!
Sheesshhh.
Shesh
Firstttttttt
you are first and managed to edit your comment, gg
Why all my fave youtube devs use tsx for react courses? Jsx pls, I barely learned js and now everything is in ts 😂🤦🏻♂️