Ordinary function execution

EC(FUNC1)

Initializing scope chain: Initializing THIS: initializing arguments: Parameter assignment: variable promotion: code execution:Copy the code

The new constructor executes

EC(FUNC2)

Initialize scope chain: 'Initialize THIS' : initializes arguments: Parameter assignment: variable promotion: code execution:Copy the code

The difference between new constructor execution and normal function execution:

Difference 1: create an empty object by default, i.e. “instance object”.

This: points to the created instance object;

This. XXX = XXX; this. XXX = XXX; this. XXX = XXX;

Difference 3: If the function does not set the return value or returns the original value type, the default return is the created instance object.