The function will extend the scope of the scope, which also derives the concept of closure. For details, you should refer to "JS Advanced Programming", which explains it in more detail.
Dynamic objects based on prototype inheritance
JS is not object-oriented like Java, but it can be inherited through prototype. However, using prototype directly will cause all derived objects to share the attributes or methods of the prototype. Therefore, when writing object-oriented code, you should pay attention to such issues.