This article is not an exploration of new knowledge, because it has no content. It just makes me feel happy when I see the knowledge of two different fields connected together or the design idea of language verified.
I read a book about JS in the holiday. Much of it is already known. But it’s interesting to see two places that feel relevant to existing knowledge. Take a picture and record it
Javascript borrows from Self’s archetypal inheritance, which might be a little strange. What is “Self”? Take a look at how JS behaves: suppose you query property X from object O
- If O does not have its own attribute X, attribute X is queried from O’s prototype object
- If the stereotype object also does not have its own property called X, but it has its own stereotype, continue to query the stereotype for that stereotype
- This process continues until the attribute X is found or an object with a null stereotype is visible in the query, which creates a chain or list of attributes to inherit through its Prototype property.
In fact, Self is derived from Smalltalk, the objective-C reference language. Accessing JS object properties and methods (if none are found, trace back up the prototype chain until null metaclass objects are found) is exactly the same as OC.
There are two Chinese PDFS for Self. SELF: The power of simplicity, the counterattack of cloning