ECMAScript 5.1, page 3:
In ECMAScript, the state and methods are carried by objects, and structure, behaviour, and state are all inherited.
What does it mean to carry state and how can an object both carry and inherit state?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
“State” essentially refers to “things the object remembers”. If an object has a property
colorwhich is set to"blue", that’s part of its state. And “carrying state” just means that it has some.So, we can (imprecisely) simplify the first part of that sentence to: “In ECMAScript, objects can store data (and methods).”
However, ECMAScript is an object-oriented language, using prototypical inheritance. That means any object may not only have its own data and methods, but it can also inherit data and methods from its parent object (its prototype).
Writing a very crude example in JavaScript: