This article is not an exploration of new knowledge. The article has no content. It is to see that the knowledge of two different fields is connected together, or the design ideas of the language are confirmed and I am happy and record it.
I read a book about JS during the holidays. Many places are known knowledge. But seeing two places feels related to the existing knowledge system, which is quite interesting. Took a photo and recorded it
Javascript borrows the inheritance of prototypes in the Self language. It may be unfamiliar. What is "Self"?
Take a look at the performance of JS: suppose to query property X from object O
- If O does not have its own attribute of X, then the attribute X will be queried from O’s prototype object
- If the prototype object does not have its own property called X, but it has its own prototype, continue to query the prototype of this prototype
- This process will continue until the property X is found or an object whose prototype is null is found
It can be seen that the object creates a chain or linked list for inheriting properties through its prototype property.
Comparing the memory layout of OC objects, the access routines of attributes or methods are consistent.
In fact, the Self language is derived from Smalltalk, which is a reference language for Objective-C. Access to JS object properties and methods (if not found, it will continue to trace back from the prototype chain until the metaclass object null is found or found). This feature is exactly the same as OC.
There are 2 Chinese PDFs for reading about the Self language. SELF: the power of , clone counterattack
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。