Yep - correct on all counts.
As a minor correction to an earlier post, you're correct that Objects are constructor functions. What I meant by "functions are objects" was that the Function constructor function inherits from the Object constructor function.
There is a data type in JavaScript called an object that, as Poryg mentioned, would be termed a struct or dictionary in other languages (or Map), which is a series of keys associated with values. They are made with the Object constructor function. Prototype is one of these data structures.
Properties refer to a key-value pairing of an object.
In JavaScript, you can create an object by using curly braces, then specifying a key, followed by a colon, followed by the value for that key. You can then reference that property with dot notation.
So someObject has the key or "property" someKey, with a value of "some value". The anotherKey property has the value 4. The hello property is a function - properties that are functions have a special term, which is "method". So we say someObject has the hello method as a property.
We can call those functions just like any other function:
Objects can also have properties that are themselves objects:
So prototype is a property on all constructor functions and prototype is an object.
As a minor correction to an earlier post, you're correct that Objects are constructor functions. What I meant by "functions are objects" was that the Function constructor function inherits from the Object constructor function.
There is a data type in JavaScript called an object that, as Poryg mentioned, would be termed a struct or dictionary in other languages (or Map), which is a series of keys associated with values. They are made with the Object constructor function. Prototype is one of these data structures.
Properties refer to a key-value pairing of an object.
Code:
var someObject = {
someKey: 'Some value',
anotherKey: 4,
hello: function() {
console.log('Hello World!');
}
};
In JavaScript, you can create an object by using curly braces, then specifying a key, followed by a colon, followed by the value for that key. You can then reference that property with dot notation.
So someObject has the key or "property" someKey, with a value of "some value". The anotherKey property has the value 4. The hello property is a function - properties that are functions have a special term, which is "method". So we say someObject has the hello method as a property.
We can call those functions just like any other function:
Code:
someObject.hello(); // prints "Hello World!"
Objects can also have properties that are themselves objects:
Code:
var nested = {
objectProperty: {
someKey: "Hi!"
}
};
console.log(nested.objectProperty.someKey); // prints "Hi!"
So prototype is a property on all constructor functions and prototype is an object.