JavaScript - Why can't I call a variable “name”?

后端 未结 2 1994
余生分开走
余生分开走 2020-12-07 03:55

Why can\'t you call a variable in JS \"name\"?

var wrapper = document.createElement(\"div\");
var name = document.createElement(\"div\");

wrapper.appendChil         


        
2条回答
  •  太阳男子
    2020-12-07 04:27

    'name' is a predefined name of implementation-dependent JavaScript objects, methods, or properties, you should avoid to use this as a name for a variable, though it's not a reserved word and might work in some browsers

提交回复
热议问题