Managing User Permissions with Bitwise Operators

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

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

  • @jeanmarcpourchel307
    @jeanmarcpourchel307 4 года назад +6

    Another great tip!
    Bitwise operators are underrated and forgotten most of the time.
    Thanks for reminding us that they exist.
    ...and as always thanks for teaching

  • @aquib-J
    @aquib-J 4 года назад +1

    I always imagined something similar if I had to write a permission system. Very neat idea. Unix continues to inspire with its clever Ideas 😃. Thanks

  • @write2sampath1
    @write2sampath1 4 года назад

    Wow !! Never knew the power of bitwise operators. This is 🔥. Would love to see more content like this.

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

    This is the best way to save permissions, if you slit it into categories, each category can have at least 32 permissions. I'm starting to use it cause i have 11 categories and each one has about 10 permissions. This is exactly what I needed to get me started. I'm using arrays for each category :)

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

    Another very cool tutorial!

  • @HappyLifege
    @HappyLifege 4 года назад

    Insightful. Thank you for this lesson!

  • @Mena_Adel2s
    @Mena_Adel2s 2 месяца назад

    Very Useful ,thx🤩🤩🤩

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

    Steve and Joanne out here dying of thirst

  • @vwesih8231
    @vwesih8231 3 года назад +3

    this.access &= ~perm can also be removed

  • @mykalimba
    @mykalimba 4 года назад +4

    Back when the cost of memory was exorbitant, any coder worth his/her salt (myself included) was encoding data like this.

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

    THANK YOU SO MUCH FOR THiS!

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

    Hi Steve, was trying this out along with the vid and I figured maybe we could check for presence of a permission before removing with XOR this way:
    if (this.access & permission) {
    this.access ^ permission
    }
    Not sure but seems to make sense. Quick question to go along with this, though: How come you choose to not go with labels for the console log of available permissions? Is there any advantage to having nums there which we'd have to look up to know what they reference?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  3 года назад

      yes. but don't forget the assignment. this.access = this.access ^ permission
      I use the getAll method to help people understand the step a bit easier.

    • @adicide9070
      @adicide9070 3 года назад +1

      @@SteveGriffith-Prof3ssorSt3v3 right, thanks!

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

    for remove function, this.access &= ~perm does the job without checking it