Array - push is not a function (javascript)

Asked 1 weeks ago, Updated 1 weeks ago, 1 views

var name = ['a', 'b', 'c']; 

There was an error doing this. name.push is not a function

However, there was no problem because the variable name was changed from name to a as follows.

var a = ['a', 'b', 'c']; 

Just in case Through JavaScript Variable name Validator I checked if name is a variable that should not be used, but it was okay. Why is it like this?

array push javascript

2022-09-20 10:58

1 Answers


I tried executing the code in both cases, but there is no problem. In fact, the variable name name doesn't matter at all. You can also check that there is no problem with the browser console or running the code in the body. Maybe it's an environmental problem.

2022-09-20 10:58

If you have any answers or tips

© 2022 pinfo. All rights reserved.