Apparently, there are some resemblance between objects in JavaScript and dictionaries in Python. Each language defines an object a little different (and there is some logic that all definitions to be the same as in physics).
How are objects alike and how do they differ between JavaSscript, Python and PHP?
7
Objects really represent the same thing in all three languages: a bundling of state and operations. What truly differs is their implementation of this idea.
The largest difference is that Python & PHP are class-based object-oriented systems, meaning that the “templates” for objects are pre-defined. When a new intance of one of these templates or classes is initialized, the class’s pattern or definition is used to shape the newly initialized object.
In JavaScript, the object system is prototype based. Rather than having some definition as to how objects of the same type ought to be defined and initialized, JavaScript takes a special object, a prototype, and clones it to create a new instance of that class.
All three languages are dynamic, which sets them apart from the C#/Java ecosystem in that you still have a good deal more flexibility. In JavaScript, Python and PHP you can dynamically add new properties and even functions at runtime whereas this is not truly possible in C#/Java.
See the following links for more information:
-
http://en.wikipedia.org/wiki/Prototype-based_programming
-
http://en.wikipedia.org/wiki/Class-based_programming
4