小编Tah*_*aza的帖子

In javascript, what is the difference between window.function(){} and var variable = function?

I am working on a javascript code where functions are defined in three different ways.

funtion f1(){}
Run Code Online (Sandbox Code Playgroud)

and second

var vaiable = f1(){}
Run Code Online (Sandbox Code Playgroud)

and third

window.f1 = function(){}
Run Code Online (Sandbox Code Playgroud)

I have read about the first two here but don't know about the last one.

Will there be a problem if I change the third one to the second one?

What are the pros and cons of third type?

Why it is used particularly?

javascript function

7
推荐指数
2
解决办法
8026
查看次数

标签 统计

function ×1

javascript ×1