The applet reports an error thirdscripterror DateValue is not defined;

Errors are reported as follows:

The error code is as follows:




Correct modification: the reference variable in the function needs this point


  console.log (DateValue) is modified to:




extension: about this in JS


this   There are six different values:

Normal function call, this is a global object or undefined

As the method of the object, this is the object

New expression, this is a newly created object based on this function

Use apply/call to specify this

Bind fixed this with bind

This in the event handler function is the DOM element (event. Currenttarget) that triggers the current event


  The points of this in the function are as follows:

      1) When a function is called as a method of an object, this points to the object

    2) When the function is called as a normal function, this points to the global object window (in browser environment) or global (in nodejs environment)

    3) This points to the newly created object when the function acts as a constructor and passes the new operator

    4) You can forcibly adjust the direction of this through the apply and call methods of function



Similar Posts: