📜  js的函数名可以和变量名一样吗 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:04:18.208000             🧑  作者: Mango

代码示例1
If you use a function name as variable name, its value is replaced by 
function body. 
So var a becomes your function a and thus your alert displays function a.

Edit But if you assign value to a like var a = "xya";. 
Then it function will be replaced by variable. As per Order of 
precedence

!!Variable assignment takes precedence over function declaration!!
!!Function declarations take precedence over variable declarations!!