Definite Assignment

Introduction to definite assignment

Variables in JavaScript are defined by using the var keyword. Unfortunately, the JavaScript runtime is very lenient on where these definitions occur and will allow a variable to be used before it has been defined.

Consider the following JavaScript code:

Get hands-on with 1200+ tech skills courses.