In JavaScript, an execution context is an environment that allows JavaScript code to be executed. During the execution context, specified code is parsed line by line, the variables and functions are stored in memory. Each time we call a function, an execution context will be created for that function to be executed. It contains the current evaluation state of the code, a reference to the code itself, and possibly references to the current lexical environments. Execution contexts are managed in a stack. Lexical environment: Each time the JavaScript engine creates an execution context, a new lexical environment will be created for that function to store variables defined in that function during the execution of that function. It is a collection of bindings, which are pairs of variable names and values. Lexical environments are created when functions are defined, and they are nested. This means that the lexical environment of a nested function can see the variables that are declared in the outer function. The relationship between execution contexts and lexical environments is that each execution context has a lexical environment associated with it. The lexical environment contains the bindings for all of the variables that are declared in the code that is being executed in that execution context. Here is an example of how execution contexts and lexical environments work in JavaScript:

function outer() {
  let x = 10;
  function inner() {
    let y = 20;
    console.log(x, y); // 10, 20
  }
  inner();
}

outer();

In this example, the `outer()` function creates an execution context. The lexical environment for the `outer()` function contains the binding for the variable `x`. The `inner()` function creates a nested execution context. The lexical environment for the `inner()` function contains the bindings for the variables `x` and `y`. When the `inner()` function logs the values of `x` and `y`, it sees the value of `x` from the outer lexical environment, and it sees the value of `y` that was declared in the inner lexical environment.