The environment of the subshell has a lot in common with the parent. Let's look at the definition first. subshell is a child process launched by a shell (when we are in front of a shell prompt) or a shell script.
In shell programming (bash in particular), "( )" starts a subshell. Whatever variables you define and assign inside the subshell is not visible to the parent process. This is usually the source of some shell programming errors.
A function in bash is essentially a command and a subshell but with the side effect of all its varables are also GLOBAL unless you add the LOCAL qualifier. The variable outside the function is visible inside the function. Thus your subshell's environment is essentially the global variable in the shell script.
As a small example in Bourne shell:
#!/bin/sh
a_function() {
echo "function is essentially a subshell"
echo "inside a_function"
echo "it can see parent variables: shellvar=$shellvar"
}
shellvar="shellvariable is set from parent shell"
echo "shellvar from parent: $shellvar "
a_function
If you run this program:
./test.sh
shellvar from parent: shellvariable is set from parent shell
function is essentially a subshell
inside a_function
it can see parent variables: shellvar=shellvariable is set from parent shell
To fully understand processes, child processes, subshells, you may want to read about fork, exec. Note the export somevar=somevalue is making somevar visible to all subsequent processes, not just the subshell. Process is organized like a tree.