Conceptually, masking involves selectively ignoring something, usually to isolate something else.

The two main uses I've familiar with are:

 1. Masking data such as bit fields or flags for bitwise operations.
 2. Masking images, often for compositing or other effects.

<br>

**Data Masking**

For an example of the first, let's say you have a [bit field](https://en.wikipedia.org/wiki/Bit_field) such as the 6502 status register:

| Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 |
| ----- | ----- | ----- | ----- | ----- | ----- | ----- | ----- |
| **N**egative flag	| o**V**erflow flag	| -	| **B**reak flag | **D**ecimal flag | **I**nterrupt-disable flag | **Z**ero flag | **C**arry flag |

`AND`ing the register with `01000000` would mask out everything except the overflow flag. So something like `if(R & 01000000)` would allow you to check for the overflow condition.

<br>

**Image Masking**

[This question](https://gamedev.stackexchange.com/q/38118/33287) examines ways to use an alpha mask to ignore unwanted portions of a texture in order to get a more complex result:

| Mask | Addition of a red hexagon sprite | Result of masking the sprite |
| ----- | ----- | ----- |
| [![mask][1]][1] | [![mask & sprite][2]][2] |[![result][3]][3] |

It's probably worth mentioning, sometimes it can be a bit ambiguous regarding whether mask is being used to refer to what is kept versus what is discarded.



 [1]: https://i.sstatic.net/Dm3KH.jpg
 [2]: https://i.sstatic.net/KLxE6.jpg
 [3]: https://i.sstatic.net/et4N7.jpg