Functions with same names in JavaScript

后端 未结 5 1334
野性不改
野性不改 2020-12-10 15:27

I tried to write a function on a JS file and another function with the same name in the page.
I expected an error but no error came and I got only the function from the

5条回答
  •  死守一世寂寞
    2020-12-10 15:32

    In JS you can redefine functions. A subsequent function with the same name as another function will overwrite it. (Subject to scope)

提交回复
热议问题