Recently, I encountered a problem where I was able to pass through the issue but couldn't fully grasp the concept behind it. If you run the code snippet provided, you'll see what's happening. Can someone clarify this for me?
function func1() {
console.log('Func1 executed.');
};
const func2 = () => {
console.log('Func2 executed.');
};
const test = () => {
window['func1'](); //This works
window['func2'](); //This doesn't work
};
button {
width: 200px;
padding: 20px;
font-size: large;
cursor: pointer;
border: 0;
background: linear-gradient(to top right, gray, silver);
color: white;
border-radius: 7px;
box-shadow: 0px 5px 7px silver;
text-shadow: 0px 2px 2px rgba(0,0,0,0.5);
}
<button onclick='test()'>Execute</button>