TypeScript Type Guards Explained

Поділитися
Вставка
  • Опубліковано 10 січ 2025

КОМЕНТАРІ • 8

  • @sandorturbucz425
    @sandorturbucz425 Рік тому

    This is one of the smarter aspects of using TS, good explanation. Some small side note, at 4:40 in real life we probably should use (unless it's on purpose) Object.hasOwn() instead of in, because the latter also finds the properties through the prototype chain.

  • @fusion.chronicles
    @fusion.chronicles 6 місяців тому

    The best explanation so far 👍

  • @rajsatraroxor9603
    @rajsatraroxor9603 7 місяців тому +1

    In last example, while changing from fruit instanceof to isTasty in, last keyword "Banana" should be changed to parameter "fruit", to check isTasty exisits or not in fruit which is passed into that function

  • @jvsvogler
    @jvsvogler 2 роки тому +2

    Really helpful, thanks a ton!

  • @SalimOfShadow
    @SalimOfShadow Місяць тому

    In the 4th example, wouldn't the comparison always return false if the two args's content are even slightly different?
    I think the type is what matters the less at that point since we're comparing it by content

  • @DerexArchives
    @DerexArchives 3 місяці тому

    thank you