Is “clear” a reserved word in Javascript?

后端 未结 4 1826
粉色の甜心
粉色の甜心 2020-11-22 02:15

I just spent a long time figuring out that I shouldn\'t use clear() as the name of a function in Javascript:


    

        
4条回答
  •  花落未央
    2020-11-22 03:10

    Good question. I think the problem is a scoping issue - your onClick="clear()" is not going to the clear function you defined, but I'm not sure where it's going. Changing it to window.clear() or a new function that simply calls your clear works.

    
        Hello!!!!





    Results will appear here.

提交回复
热议问题