Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
180 views
in Technique[技术] by (71.8m points)

javascript - Position of a Immediately Executing Function

I'm learning Node.js, and there is something I cannot understand.

I have a function and a Immediately Executing Function, like this:

(
    function foo(){
        console.log('foo was executed')
    }
)()

function foofun(){
    return 123
}
console.log(foofun())

When the IEF is at the beginning, the code executes right, but when the foofun() and it's console.log are at the beginning, this gave me this error:

enter image description here

Does it matters the position where is located the IEF? Why this happens?

question from:https://stackoverflow.com/questions/65888428/position-of-a-immediately-executing-function

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...