I tried to execute this code:
html code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="variables.js"></script>
</head>
<body>
</body>
</html>
js code:
const var1 = 10;
const var2 = 'Hello world';
const var3 = true;
const foo = function(){
console.log("Whats up !!");
}();
foo;
console.log(typeof(foo));
When I am opening this javascript file and executing this javascript over browser chrome devtools inspector , its neither letting me create the founction foo(), nor is it letting me use foo().
I am not able to figure out the reason for it. Help is appreciated.
Tried to execute js in chrome dev tools.
Did not worked for me.
Error code:
foois not a function in your code.