Block Scope and Lifetime
JavaScript adds one more level: let and const are block scoped, meaning they exist only inside the nearest curly braces, including a loop body or an if statement. Python has no block scope, a variable made inside an if or for survives afterwards.
Lifetime is the other half of the story. A local variable lives only as long as the call that created it. Call a function three times and you get three separate, independent lifetimes.
Mark this lesson complete
Signed in, your progress follows you to every device.