Managing User Permissions with Bitwise Operators

  Рет қаралды 6,778

Steve Griffith - Prof3ssorSt3v3

Steve Griffith - Prof3ssorSt3v3

3 жыл бұрын

There are frequently different types of users on a website who have different levels of access and different task permissions. This tutorial explains how you can use a single integer to represent any combination of access permissions, all thanks to the bitwise operators. The bitwise operators will let us manipulate and interrogate numbers at the binary level.
Code from video: gist.github.com/prof3ssorSt3v...
Bitwise operator basics video: • Managing User Permissi...

Пікірлер: 18
@jeanmarcpourchel307
@jeanmarcpourchel307 3 жыл бұрын
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 3 жыл бұрын
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 3 жыл бұрын
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 :)
@HappyLifege
@HappyLifege 3 жыл бұрын
Insightful. Thank you for this lesson!
@chesterxp508
@chesterxp508 2 жыл бұрын
Another very cool tutorial!
@mykalimba
@mykalimba 3 жыл бұрын
Back when the cost of memory was exorbitant, any coder worth his/her salt (myself included) was encoding data like this.
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 жыл бұрын
Yep. As we reach the limits of Moores law it will become important again.
@smajdovamanka
@smajdovamanka Жыл бұрын
THANK YOU SO MUCH FOR THiS!
@mona.supremacy
@mona.supremacy 3 жыл бұрын
This is super confusing that such a high standard of quality for the content didn't attract an appropriative amount of followers, regardless of how the channel has been promoted since its creation. You're a great teacher and I am happy that I found this channel. I will definitely recommend it to everyone who's interested in learning JS. Is there a chance to see some videos on built-in Data Structures in JS and its core mechanics?
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 жыл бұрын
Data structures is on my todo list
@mona.supremacy
@mona.supremacy 3 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 great! Guess I'm already liked that, haha
@vwesih8231
@vwesih8231 3 жыл бұрын
this.access &= ~perm can also be removed
@pnutbtrr7717
@pnutbtrr7717 2 жыл бұрын
Steve and Joanne out here dying of thirst
@grijjly6091
@grijjly6091 Жыл бұрын
for remove function, this.access &= ~perm does the job without checking it
@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 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 right, thanks!
OpenWeatherMap API Tutorial 2021
26:18
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 76 М.
когда повзрослела // EVA mash
00:40
EVA mash
Рет қаралды 4 МЛН
What are Bit Masks, and how do I use them? (examples in C)
3:04
Jacob Sorber
Рет қаралды 52 М.
JS Code Structure Moving Beyond Beginner
21:31
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 13 М.
Enums, Flags, and Bitwise operations [C# / DotNet]
9:09
Data Vids
Рет қаралды 2,8 М.
JavaScript Proxies
22:54
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 11 М.
JavaScript Bitwise Operators
9:26
Programming with Mosh
Рет қаралды 99 М.
The Hidden World of requestAnimationFrame
9:22
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 31 М.
Tagged Template Literals
11:11
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 10 М.
JavaScript Classes vs Prototypes
14:39
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 62 М.
JS Global Variables, Global Properties, and globalThis
6:41
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 21 М.
Using JavaScript Strict Mode
13:04
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 6 М.
когда повзрослела // EVA mash
00:40
EVA mash
Рет қаралды 4 МЛН