#18: Master TypeScript Unions and Intersections - Real-Life Examples & Practical Tips 🚀

Поделиться
HTML-код
  • Опубликовано: 2 дек 2024

Комментарии • 38

  • @ThapaTechnical
    @ThapaTechnical  Год назад +1

    🚀 For Source Code & Home Assignment 👉 thapatechnical.shop/courses/typescript-crash-course
    😊 Become Member, get access to perks, free Source code, & more..
    ruclips.net/channel/UCwfaAHy4zQUb2APNOGXUCCAjoin
    😍 Check my Instagram to Connect with me: instagram.com/thapatechnical
    👩‍💻 Discord Server Link for Programmer to Hangout: discord.gg/MdScmCsua6

    • @omrout3957
      @omrout3957 Год назад

      Sir I pay for source code ₹50 rs but I didn't get source code

  • @subhomoypal7982
    @subhomoypal7982 Год назад +15

    Your auto prefix typescript plugin create a confusion for us.

  • @Radhe_radhe2929
    @Radhe_radhe2929 Год назад +1

    Ekdum khatarnak samjh aagya😊😊❤🎉

  • @adithyang6672
    @adithyang6672 Год назад +1

    Bhai app legend hoo kya padhatee hoo, matlab samaj mei bhi aajata haii bore bhi nhi hotaa,,, ekdum unique u are the best youtuber......conecpts sikhte bhi hoo aur entertainment bhi karte hoo please keep making such awesome videos

  • @yash-eb9zu
    @yash-eb9zu Год назад +1

    Bhaiya mern stack application azure par kaise deploy karna uspar video please

  • @rishiraj2548
    @rishiraj2548 Год назад

    Thanks a lot

  • @ashishkumar-jo7cj
    @ashishkumar-jo7cj 3 месяца назад

    Mereko lgta h union or Intersection me thoda bahut gadbad h union kehta h ki tum multi types me se kisi ek hi type ko use kr sakte ho jabki intersection me aap dono types ko include kr sakte ho
    For example
    type Cat = {
    meow: () => void
    }
    type Dog = {
    bark: () => void;
    }
    // For union
    type Pet = Dog | Cat;
    // For Intersection
    type Pet1 = Dog & Cat;
    Ab Union me hum ya to Cat type ko use kr sakte h ya fhir Dog ko
    Agae Catcor Dog dono ki properties ko use krna h to hume Intersection ko select krna pdega

  • @techsavy5669
    @techsavy5669 4 месяца назад +1

    return (type of value === "number") ? ('$' + value. to Fixed(2)) : (type of value === "string") ? (value[0].to Upper Case() + value. slice(1)): (value === true ? "Yes" : "No");

  • @nontechbg
    @nontechbg 7 месяцев назад

    Good 👍

  • @ashishkumar-jo7cj
    @ashishkumar-jo7cj 3 месяца назад

    Ye intersection kam or AND or OR Logical Operation jyada lg rhe hai jahaan Union ka kaam OR Logical Operator kr rha h or Intersection ka kaam AND Logical Operator kr rha h or dono ke symbols bhi same h bas yahaan single | or & use ho rhe h

  • @shubhamsharma-wo8fz
    @shubhamsharma-wo8fz 3 месяца назад

    ye arrow function k time 2 times Q ata voide , userInput : () => voide = () : voide => {} ? ye structor samaz nai aya

  • @itspiyush_23
    @itspiyush_23 8 месяцев назад

    Extension Name?

  • @runtimeerror7773
    @runtimeerror7773 Год назад

    Devknus for reactjs

  • @ballagtech7430
    @ballagtech7430 Год назад

    assignment wale pdf se kuchh copy nhi ho raha hai

  • @khyzersaleem
    @khyzersaleem 4 месяца назад

    extension?

  • @PradeepSingh-d6x
    @PradeepSingh-d6x 5 месяцев назад +1

    Dekh raha hai ha vinod 😁😁😁😁

  • @satyam_code
    @satyam_code 3 месяца назад +1

    💙💜

  • @rishabhmalewar
    @rishabhmalewar 7 месяцев назад +1

    const inputValue = (value: string | boolean | number) => {
    if (typeof value === 'number') {
    return "$" + value.toFixed(2)
    } else if (typeof value === 'boolean') {
    if (value === true) {
    return "Yes"
    } else {
    return "No"
    }
    } else if (typeof value === 'string') {
    return `${value.charAt(0).toUpperCase()}${value.substring(1)}`
    } else {
    throw new Error("Invalid input data");
    }
    }
    console.log(inputValue(3.143527))
    console.log(inputValue("typescript"))
    console.log(inputValue(false))

  • @CosMIcAkaSh1111
    @CosMIcAkaSh1111 3 месяца назад

    union task:
    const formatUserInput = (input: string | number | boolean): string | number | boolean => {
    if(typeof input == "string"){
    return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase()
    }else if(typeof input == "boolean"){
    return input ? "yes" : "no"
    }else if(typeof input == "number"){
    return `$${input.toFixed(2)}`
    }else{
    throw new Error("Invalid input")
    }
    }
    console.log(formatUserInput("hello world"))
    console.log(formatUserInput(true))
    console.log(formatUserInput(100))

  • @jagdishjena9058
    @jagdishjena9058 Год назад

    🆃🅷🅰🅽🅺 🆈🅾🆄 🆂🅾 🅼🆄🅲🅷 🆂🅸🆁.👑👑👑👑👑👑

  • @RajneeshYashkirti2025
    @RajneeshYashkirti2025 Год назад

    🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉

  • @shahhussain7192
    @shahhussain7192 4 месяца назад

    let userInput = (value: number | string | boolean): number | string => {
    if(typeof value === "number") {
    return '$' + value + '.00';
    }
    else if (typeof value === 'string') {

    return value.charAt(0).toUpperCase() + value.slice(1);
    }
    else {
    return value=== true ? "Yes" : "No"

    }
    }

    console.log(userInput(20));
    console.log(userInput('gufran'));
    console.log(userInput(true));

  • @RalKrish
    @RalKrish 20 дней назад

    const booleanFn_1 = (value: string | boolean | number): void => {
    switch (typeof value) {
    case 'string':
    value = value.charAt(0).toUpperCase() + value.slice(1)
    console.log(value);
    break;
    case 'number':
    value = `$${value.toFixed(2)}`
    console.log( value);
    break;
    case 'boolean':
    value === true ? console.log('Yes') : console.log('No')
    break
    default:
    console.log( value, 'No worries');
    }
    }
    booleanFn_1(15);
    booleanFn_1(true);
    booleanFn_1(false);
    booleanFn_1('venom');

  • @DEEPANSHU_NAG
    @DEEPANSHU_NAG Год назад

    const formatFunction = (value:number|boolean|string):string =>{
    if(typeof value==="number")
    {
    return `$ ${value/100}`;
    }
    return (typeof value==="boolean" && value==true) ? "Yes" : "No";
    /*if(typeof value==="string")
    {
    return value.charAt(0).toUppercase() + value.slice(1);
    }*/
    }
    console.log(formatFunction(856));
    console.log(formatFunction(true));
    //console.log(formatFunction("manjeet"));
    Isme commented part me error h plz fix..

    • @subhomoypal7982
      @subhomoypal7982 Год назад +1

      .toUppercase() asa nahi ha, asa hoga .toUpperCase()

    • @DEEPANSHU_NAG
      @DEEPANSHU_NAG Год назад

      @@subhomoypal7982 abhi v error h uppercase wale line me
      main.ts(9,22): error TS2339: Property 'charAt' does not exist on type 'string | number | boolean'.
      Property 'charAt' does not exist on type 'number'.
      main.ts(9,54): error TS2339: Property 'slice' does not exist on type 'string | number | boolean'.
      Property 'slice' does not exist on type 'number'.

    • @DEEPANSHU_NAG
      @DEEPANSHU_NAG Год назад

      @@subhomoypal7982 uppercase correct krne k baad v error h

    • @adithyang6672
      @adithyang6672 Год назад

      its toUpperCase() camel case hai naa

    • @DEEPANSHU_NAG
      @DEEPANSHU_NAG Год назад

      @@adithyang6672 ha usme v error aa rha h