JavaScript is a programming language created at Netscape (now part of Mozilla) in 1995. Due to a trademark conflict with Sun Microsystems (now Oracle), it could not be officially named "JavaScript," so the standardized version is called ECMAScript. The creators submitted JavaScript to ECMA (European Computer Manufacturers Association) to standardize its specifications.
const postPath = path.join(
process.cwd(),
'src',
'pages',
'javascript',
'introduction',
'data.md'
);
Within the function, we first declare the name
variable with the var
keyword. This means that the variable gets hoisted (memory space is set up during the creation phase) with the default value of undefined
, until we actually get to the line where we define the variable. We haven't defined the variable yet on the line where we try to log the name
variable, so it still holds the value of undefined
.
Variables with the let
keyword (and const
) are hoisted, but unlike var
, don't get initialized. They are not accessible before the line we declare (initialize) them. This is called the "temporal dead zone". When we try to access the variables before they are declared, JavaScript throws a ReferenceError
.