Please run the snippet and observe the output code to understand my issue. I stripped the problem down and made the console.log
s easy to understand.
It seems that the suggested syntax for accessing object properties works in synchronous functions but does not work in an asynchronous function.
The suggested syntax to access object properties does not to work inside of async functions. Is there a logical reason for this difference in behavior, have I overlooked something in my syntax, or is this an inconsistency in JavaScript’s async objects.
var goo = (function() {
let a = "as";
let b = "boot";
return {
a,
b
}
})();
(function() {
console.log("console.log 1:", goo)
console.log("console.log 1.5:", goo.a);
console.log("console.log 1.75:", goo["a"]);
})();
var go = (async function() {
let a = "asile";
let b = "beet";
return {
a,
b
}
})();
(async function() {
console.log("console.log 2:", await go);
console.log("console.log 2.5:", await go.a);
console.log("console.log 2.75:", await go["a"]);
})();