Just to expand and improve some of the answers above:
First, I will check the mkdir man page for GNU Coreutils 8.26 - it gives us this information about the options '-m' and '-p' (can also be given as -mode = MODE and are parents, respectively):
... set [s] the file mode (as in chmod), and not a = rwx - umask
... no error, if it exists, create parent directories if necessary
Statements are vague and unclear in my opinion. But basically it means that you can create a directory with the permissions indicated by the "numeric note chmod" (octal), or you can go "differently" and use / umask.
Side note: I say “differently”, since the umask value is actually what it sounds like - a mask by hiding / removing permissions rather than “providing” them, as with the octal chmod notation.
You can run the command created by the umask shell to find out what your 3-digit umask is; for me it's 022 . This means that when I execute mkdir yodirectory in a given folder (say mahome) and stat , I get output similar to this:
755 richard:richard /mahome/yodirectory
Now, to add just a little more about those eight-step resolutions. When you create a directory, "your system" takes your default perms directory "[which applies to new directories (its value should be 777)] and a slap on the yo (u) mask, effectively hiding some of these perms." My umask is 022 - now if we “subtract” 022 from 777 (technically, subtraction is redundant and not always correct - we actually turn off perms or mask them) ... we get 755, as indicated (or "statted") earlier .
We can omit “0” before 3-digit octal (so that they should not be 4-digit), because in our case we did not want (or rather did not mention) any stickybits, setuids or setgids (you may want to study them By the way, they can be useful since you are going to 777). In other words, 0777 implies (or equivalently) 777 (but 777 is not necessarily equivalent to 0777 - since 777 only sets permissions, not setuids, setgids, etc.)
Now, to apply this to your question in a broader sense, you already have several options. All of the above answers work (at least for my main reasons). But you can (or most likely) run into problems with the above solutions when you want to create subdirectories (subdirectories) with 777 access rights at the same time. In particular, if I do the following in mahome with umask 022:
mkdir -m 777 -p yodirectory/yostuff/mastuffinyostuff
I will get perms 755 for yodirectory and yostuff , only 777 perms for mastuffinyostuff . So it seems that umask is all that is removed on yodirectory and yostuff ... to get around this, we can use a subshell:
( umask 000 && mkdir -p yodirectory/yostuff/mastuffinyostuff )
and what is he. 777 perms for yostuff, mastuffinyostuff and yodirectory.