'Why does adding function as in A3 or removing function as in B3 cause errors?
Why does adding function as in A3 or removing function as in B3 cause errors?
Version A1
let x = {
func: function () {
console.log(`Hi`);
}
}
Version A2
let x = {
func() {
console.log(`Hi`);
}
}
Version A3 (Not Working)
let x = {
function func() {
console.log(`Hi`);
}
}
Version B1
let func = function () {
console.log(`Hi`);
}
Version B2
function func() {
console.log(`Hi`);
}
Version B3 (Not Working)
func() {
console.log(`Hi`);
}
Solution 1:[1]
The reason is that the syntax and grammar defined for JavaScript does not provide for the validity of the code you have written.
Simply put, the code is invalid.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | VLAZ |
