Portál AbcLinuxu, 12. května 2025 21:19
foo.bar=()=>{}a tímto zápisem
foo.bar=function(){}Děkuji za vysvětlení.
Řešení dotazu:
const obj = { name: 'John Reese', nameGetterAnon: function() { return function() { return this.name; } }, nameGetterAnonBound: function() { const f = function() { return this.name; }; return f.bind(this); }, nameGetterArrow: function() { return () => { return this.name } }, } const anon = obj.nameGetterAnon(); const anonBound = obj.nameGetterAnonBound(); const arrow = obj.nameGetterArrow(); console.log(anon()); console.log(anonBound()); console.log(arrow());
undefined John Reese John Reese
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.