Skip to content

Instantly share code, notes, and snippets.

@joe-oli
Created October 29, 2019 23:35
Show Gist options
  • Save joe-oli/622706813b651e9bcdbeb432add3cf36 to your computer and use it in GitHub Desktop.
Save joe-oli/622706813b651e9bcdbeb432add3cf36 to your computer and use it in GitHub Desktop.
undefined in javascript
The definition of undefined in ECMAScript 1st edition is
Undefined is a primitive value used when a variable has not been assigned a value.
It is also used:
as the returned value when trying to retrieve an object property that does not exist (after looking for it over the prototype chain).
1. If O doesn’t have a property with name P, go to step 4.
2. Get the value of the property.
3. Return Result(2).
4. If the [[Prototype]] of O is null, return undefined.
5. Call the [[Get]] method of [[Prototype]] with property name P.
6. Return Result(5).
as the default value for parameters that are not specified in a function call
If the caller supplies fewer parameter values than there are formal parameters, the extra formal parameters have value undefined.
as the void operator returned value
The production UnaryExpression : void UnaryExpression is evaluated as follows:
1. Evaluate UnaryExpression.
2. Call GetValue(Result(1)).
3. Return undefined.
as the default value returned by return in function calls
The RETURN statement
If Expression is omitted, the return value is the undefined value.
as the default function call result if it includes no return statement
… a function with an “empty body”; if it is invoked, it merely returns undefined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment