If I have the following object literal, I understand that val
and prop
are properties of the obj object.
const obj = {
val: 7,
prop: function() {
alert("prop " + this.val);
},
met() {
alert("met " + this.val);
}
};
obj.prop();
obj.met();
Property prop
holds a reference to an anonymous function. Such a property is also referred to as a method.
In Visual Studio IntelliSense:
prop
is referred to as property,met
is referred to as method.
But
- What is
met
? - How does it differ from
prop
? - When to use
prop
syntax and whenmet
?