Note any errors caused by code irregularities.

Duplicate: Sets the closure and the immediate function, executing the closure first, followed by writing the immediate function.

First look at the code uncurrying: a method that returns a function

Function.prototype.uncurrying = function() {
  var _this = this
  return function () {
    var obj = Array.prototype.shift.call( arguments )
    console.log(obj)
    return _this.apply( obj, arguments)}}Copy the code

Compare two pieces of code

// The first segment will fail
let push = Array.prototype.push.uncurrying()
(function() {
  push(arguments.4)
})([1.2.3])

 // The second segment is running properly
let push = Array.prototype.push.uncurrying();
(function() {
  push(arguments.4)
})([1.2.3])
Copy the code

Comparison of the uppercase codes.push.uncurrying() differs only with a semicolon

The first paragraph displays an error, as shown below

at Function.push (<anonymous>) at \test\omg.js:6:18 at Object.<anonymous> (\test\omg.js:12:1) at Module._compile (internal/modules/cjs/loader.js:1200:30) at Object.Module._extensions.. js (internal/modules/cjs/loader.js:1220:10) at Module.load (internal/modules/cjs/loader.js:1049:32) at Function.Module._load (internal/modules/cjs/loader.js:937:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47Copy the code

There is no semicolon at compile time, and two lines are compiled into one, resulting in a runtime error.

This is the result of compiling without a semicolon. It is clear that the next line of self-executing functions is taken as an argument to the closure

let push = Array.prototype.push.uncurrying()(function() { push(arguments.4) })([1.2.3]);
Copy the code