All about the BigInt - New Javascript Data Type

Поделиться
HTML-код
  • Опубликовано: 13 июл 2024
  • We will take a dive into a ECMAscript 2020 feature coming soon to Javascript: the BigInt primitive data type. Learn everything you need to know about the bigInt in this video and level up your Javascript skills!
    Optional Chaining & Nullish Coalescing Operator: • Optional Chaining & Nu...
    Four Promise Functions: • Promise.all | Promise....
    🗄 Resources:
    ECMAscript Finished Proposals: github.com/tc39/proposals/blo...
    MDN BigInt: developer.mozilla.org/en-US/d...
    Amazing article: www.smashingmagazine.com/2019...
    🔑 Key Concepts:
    - BigInt
    #BigInt #DataTypes #JavaScript2020
  • НаукаНаука

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

  • @AngleCoding
    @AngleCoding  4 года назад +14

    Hey guys, Justin here! I just realized that the sort() did not sort it correctly.... hmm 🤔
    After doing some digging, I realized that the sort() function without any parameters actually sorts them in the LEXICAL ordering, not the actual number values itself! So sort() between a mixture of numbers and bigInts will only work properly when dealing with non-negative numbers

    • @farhanaditya2647
      @farhanaditya2647 3 года назад +2

      To be precise, it will coerce the number into a string and sort them by their character order in UTF-16. So, no, they won't work properly to sort numbers.
      ```
      let arr = [1,2,3,10,20,30,100,200,300];
      arr.sort() // [ 1, 10, 100, 2, 20, 200, 3, 30, 300 ]
      ```

    • @Cloud9er
      @Cloud9er 2 года назад

      if you spell out the sort mechanism it will work:
      [10, 5, 15n, 0, -1, 20, -2n, 25, -3n, 30, -4, -5].sort((a, b) => {
      if (a > b) {
      return 1;
      } else if (a < b) {
      return -1;
      } else if (a === b) {
      return 0;
      }
      })

  • @farhanaditya2647
    @farhanaditya2647 3 года назад +2

    This channel is so underrated. Thank you so much for providing easy-to-understand videos. These kinds of videos are rare in the world of programming. Now I want to know about Symbol too :)

  • @Viralvlogvideos
    @Viralvlogvideos 2 года назад +1

    WOW, ur accent is easy to understand and u got perfect timing of explaining things. Continue what your doing Justin One day you will reach million subcribers. If possible please make full tutorial on JS . Thank you

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

    this is extremely informative! keep making such videos brother.

  • @yakumo.nightspider
    @yakumo.nightspider Год назад

    Succinct explanation with the necessary amount of appreciation. Subscribed.

  • @metanomial
    @metanomial 4 года назад +3

    BigInt has a lot of potential with bitwise operators and binary data processing.
    But I think the most common use case for BigInt will be emulating 64-bit integers; especially in context of BigInt64Array and it's unsigned counterpart.

  • @c99rahul
    @c99rahul 3 года назад

    Thanks Justin, for the clear-cut explanation. I'm on the same boat as you, won't be needing to use BigInt anytime soon. That said, I'd also like to be aware about its use cases.

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

    Love this video. It taught me a lot of things 🖤

  • @saumyaverma9581
    @saumyaverma9581 3 года назад

    Thank you so much for it. You said that maybe you will never use BigInt. But It helped me making a project asked in an internship interview.

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

    Thank you, Justin .

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

    thank you very much for this information

  • @kolavithonduraski5031
    @kolavithonduraski5031 3 года назад

    you have cool style of explaining.
    subscribed 👍

  • @gamersoul1098
    @gamersoul1098 3 года назад

    you got the point bro about 'SYMBOL'

  • @garyfxxk
    @garyfxxk 3 года назад

    Nice explaination

  • @itsjmmariano
    @itsjmmariano 3 года назад

    Thank you :)

  • @duchailu
    @duchailu 2 года назад

    well, as a fun exercise for a newbie front end dev, i wanted to create an "incremental" game (kind of useless game for people who like to see unnecessarily large numbers increase forever):D i was'nt aware at first of the 10^308 limit of the number type of javascript, this might be the solution i need !! i might need to restart my app from the start though ....

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

    🔥

  • @an1x70
    @an1x70 3 года назад

    sort works because it by default converts every value to a string. that is why it is possible to sort them but the result will be unexpected, like in your example -1 will be before -4n

  • @medAmineRg
    @medAmineRg 3 года назад

    thankyou

  • @kqvanity
    @kqvanity 2 года назад +1

    The methods you've mentioned are remotely connected to immutability, and has outright nothing to do with primitive values from non-primitive ones. for instance, there are other methods that alter the memory location being by referenced by variables in place, rather than the returning the result of the computation back (and printing them out to stdout within this repl chrome console prompt).
    As for arrays, their typical assignment gets them to copy the plain reference, rather than allocating yet another place at memory to accommodate the same value of the datatype initially referenced.
    You've honestly mixed and matched between js concepts at first, and the clip should have been more confined to bigint itself which was really comprehensive. thanks!

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

    bigint has lot of scope for web3

  • @nazrinsuleymanova9381
    @nazrinsuleymanova9381 3 года назад

    symbol is an anonymous datatype :)

  • @froggyy
    @froggyy 3 года назад

    I want BigFloat

  • @MundoFinky
    @MundoFinky 4 года назад +1

    Why the fuck didn't they add a way to fix 0.1+0.2 not being equal to 0.3 alongside with this? 😐