var person = {
firstName: "John",
lastName : "Doe",
id : 5566,
fullName : function() {
console.log(this.firstName + " " + this.lastName)
}()
};
Почему возвращает undefined undefined? Можно создать самовызывающиеся методы объекта внутри самого объекта?
const person = {...}; person.fullName = (function(){...})();– nörbörnën Jun 15 '21 at 19:34const f = function (msg) { console.log(msg); }; const obj = { test: (f('iife? not exactly'), f), /*...*/ }; obj.test('but works');– yar85 Jun 16 '21 at 20:50