JS funkcjonuje wewnątrz obiektów
var person = {
name: "Fred",
sayName: function() {
console.log(this.name);
}
};
person.sayName();
Glamorous Goldfinch
var person = {
name: "Fred",
sayName: function() {
console.log(this.name);
}
};
person.sayName();
var obj = {
prop1: 5,
obj2: {
prop1: [3, 6, 3],
prop2: 74,
prop3: {
str: "Hello World"
}
}
};
console.log(obj.obj2.prop3.str); //output: "Hello World"
var obj = {
func: function(a, b) {
return a * b;
}
};
obj.func(3, 6); // 18