Typescript Tutorial #6: Differences ANY vs UNKOWN Types with Practical Examples🔥

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

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

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

    Guys Assignment jo diya jai.. Comments krke share jarrur krna🎉

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

      Home Works Boolean program
      function isDivisibleBy4And8(a: number): boolean {
      // return a % 4 ===0 && a%8 ===0;
      if (a % 4 === 0 && a % 8 === 0) {
      return true;
      } else {
      return false;
      }
      }
      // fun call
      console.log(isDivisibleBy4And8(48));
      HomeWorks BigInt
      let sum = bigNumber + anotherBigNumber;
      console.log(`Sum is ${sum}`);
      let difference = bigNumber - anotherBigNumber;
      console.log(`Difference is ${difference}`);
      let product = bigNumber * anotherBigNumber;
      console.log(`Product is ${product}`);
      let division = bigNumber / anotherBigNumber;
      console.log(`Division is ${division}`);
      Answer : ->
      [
      Sum is 99079191802150916
      Difference is -81064793292668934
      Product is 811296384146066771921893777735675
      Division is 0
      ]

    • @Support-Phalestine
      @Support-Phalestine Год назад

      Bro video ma CHOTI so chez ko itna lamba na kia kro jaldi samghaya kro ❤❤ otherwise love you ❤❤

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

      l
      et sum = bigNumber+anotherBigNumber
      console.log(sum)
      let difference = anotherBigNumber-bigNumber
      console.log(difference)
      let product = bigNumber*anotherBigNumber
      console.log(product)
      let division = anotherBigNumber/bigNumber
      console.log(division)

  • @azurecoders
    @azurecoders 7 месяцев назад +3

    bohat vip course ha brother thanks for hardworks and efforts. JAZAKALLAH

  • @jonnysharan4393
    @jonnysharan4393 10 месяцев назад +1

    type safety and type checking is helpful so use unknown above the any it has better advantage and also get the idea of type when we assign value

  • @jonnysharan4393
    @jonnysharan4393 10 месяцев назад +1

    we learned in this video about the any type and unknown type . ant type used for the type where we do not assign any type but still want to perform operation its like simple js. but it is not a good way to add cause it is not checcking type and stype safety we compromise. so for that we have unknows type to help in that . we could use unknown type and get the type safety and type checking to perfoe=rm some operation like if (type of a=== boolean) to check the type and if we talk about the type safety we could perfom methods for that type it is available or not .

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

    Awesome

  • @NabeelKhan-l5u
    @NabeelKhan-l5u Месяц назад

    Superb!

  • @devanshuyoo
    @devanshuyoo 11 месяцев назад

    Badiya h

  • @saicharanmuthyapwar9387
    @saicharanmuthyapwar9387 11 месяцев назад

    🎉

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

    acha hai

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

    Best teacher. Best tutorial ❤

  • @PoojaGupta-pm8ok
    @PoojaGupta-pm8ok 8 месяцев назад

    vedio pasand aaya isiliye like karenge hum.

  • @chinubiswajit
    @chinubiswajit 9 месяцев назад

    Its Usefull

  • @MuhammadUsmanAli786
    @MuhammadUsmanAli786 9 месяцев назад

    Great!

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

    Good content 🔥

  • @devtyagi4481
    @devtyagi4481 10 месяцев назад

    nice series

  • @neelprajapati6690
    @neelprajapati6690 9 месяцев назад

    Hi Sir Please make a video for your vs studio code. We also want vs studio code like yours.

  • @JamalKhan-zl8lu
    @JamalKhan-zl8lu 6 месяцев назад

    Great tutorial ...

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

    RUclips per typescript + react js k projects bht kam he please make some!

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

    Thapa sir react js or type script k sth kch projects bh banai please

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

    nice video

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

    nice

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

    Also if we use any then sonar will throw major issue bcoz by default type is any only so there is no usage of typescript if we are using any.

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

    Cool, I am in Bootcamp but you are always awesome

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

    ♥💙

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

    yes we want the video

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

    Mast laga bhaiya ❤❤

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

    Bro the example you said type checking is also possible with any bro

  • @tanyanagi6871
    @tanyanagi6871 11 месяцев назад

    Frome wher we can get the source code link for definition and questions?

  • @sarbajitacharjee1195
    @sarbajitacharjee1195 9 месяцев назад

    what extension used for This fancy code

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

    ❤❤❤

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

    Bahut acha LAG RAHA HAI BHAIYA PADHNE ME BAS AISE HI PADHATE JAO BHAIYA TYPESCRIPT ME VIDEOS KITNI AAYEGI ?

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

    Thank you so much sir.

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

    videos are in reverse order like video number 6 is on order number 1, please correct it.

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

    5:45 but you didn’t declare your variable myFavNum1 with type unknown.
    You have not wrote let myFavNum1:unknown =55

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

    When this series is going to be completed?

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

    parhatai easy cheezai ho aur assignment pta nhi kya dai daitai ho, jo assignment daitai ho next video mai uska solution bhi share kr diya krai ap

  • @ishaanrawat9846
    @ishaanrawat9846 9 месяцев назад

    bro typescript ka source code khareedna h please provide link ?

  • @KunjVaishnani-j7s
    @KunjVaishnani-j7s Год назад

    which theme is this . vscode

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

    haa dekhana chahenge

  • @SyedaNoor-v6o
    @SyedaNoor-v6o 7 месяцев назад

    mera bigint ka output nahi aa raha.

  • @zia429
    @zia429 6 месяцев назад

    let a= 8%4===0
    console.log(a);
    plz sir

  • @ArshadKhan-rk9ck
    @ArshadKhan-rk9ck Год назад

    First comment

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

    Next 13 ki series aayegi kya

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

    program boolean
    function isEven(a:number):boolean{
    console.log(a);
    return a%2==0;
    }
    let result = isEven(9);
    console.log(result);
    function isDivisibleBy(number :number):boolean {
    console.log(number)
    if (number%4==0 && number%8==0){
    return true;
    }
    else{
    return false;
    }
    }
    console.log(isDivisibleBy(16));
    console.log(isDivisibleBy(32));
    console.log(isDivisibleBy(20));
    console.log(isDivisibleBy(7));

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

    @ThapaTechnical Please share how to fix bigint issue error on running tsc command

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

    If else statement completely wrong

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

      It is perfectly correct Bhai.
      But may I know what is wrong in that?

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

      @@ThapaTechnical he just do that for your replay he is big fan of you like we are

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

    Hy brother 🖐
    I don't understand use of unknown kindly explain it in detail u use unknown in async await function like
    async function fetchDtaa(): Promise
    but we all know that async function always return a promise so why u use unknown
    and we can also check type of and we can also check type of any like
    let fav: any = 12;
    fav = true;
    console.log(typeof fav);
    so why we use unknown
    please explain

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

      Even i didnt get the same thing

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

      I still have doubt regarding this “any vs unknown”, but the promise thing, I know that. We know the function will return promise but what type of value will promise return when resolved, so we use that in angular brackets such as . Let say there is a function which is used to get user’s address by using an api. So we can declare function as : function getUserAddress(userId:number) : Promise { … }
      Now if we use await,
      const addr:string = await getUserAdrress(10);
      This will work and typescript will know the datatype of resolved value.
      If you try to do something like,
      const result:number = await getUserAddress(5);
      Typescript will give error because you mentioned that promise will resolve to a string value, but you storing the result in a variable of type number

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

      Also now i got the main difference between any and unknown. Just googled this,
      If you use following:
      let n:any = 7;
      n = n.toUpperCase();
      This will not give any compile time error, but if you use following
      let a:unknown = 10
      console.log(a.toUpperCase())
      It will give compile time error, and force you to use type checking i.e
      let a:unknown = 10
      if ( typeof a === “string”) {
      console.log(a.toUpperCase())
      }
      Hope you get this

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

      Here is an Example
      // this is any
      let apple: any = 12;
      apple = "hello";
      apple = true;
      apple = 12312312;
      let newApple = apple + 12; // we can do it. it will work
      let banana: unknown = [1, 2, 3, 4, 5]; // currently for example, it is coming from api, which is unknown to us
      // let newBanana = banana.map((el:number) => el); // if we try to map directly, it will wont let you compile. because maybe it is null or something else.
      // when you got to know that it's an array only then you perform map on it, so following code will compile without error
      if (Array.isArray(banana)) {
      let newBanana = banana.map((el: number) => el);
      console.log("newBanana: ", newBanana);
      }
      but if you do it with any, there is no issue and you might endup with null or undefined error.

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

    Thapa sir react js or type script k sth kch projects bh banai please

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

    RUclips per typescript + react js k projects bht kam he please make some!

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

    RUclips per typescript + react js k projects bht kam he please make some!

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

    Thapa sir react js or type script k sth kch projects bh banai please