I am unsure why console.log(this)
returns undefined in javascript files. Shouldn't it be the global object since it is not inside a function. Is it something to do with modules?
Index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>React App</title>
<script src="node_modules/react/umd/react.development.js"></script>
<script src="node_modules/react-dom/umd/react-dom.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.17.0/babel.min.js"></script>
</head>
<body>
<div id="app"></div>
<script type="text/babel" src="./src/components/Child.js"></script>
<script type="text/babel" src="./App.js"></script>
</body>
</html>
App.js
console.log(this)
const App = () => <Child />
ReactDOM.render(<App />, document.getElementById('app'))
Child.js
console.log(this)
const Child = () =>
<div>
<h3>Child</h3>
</div>
Both console.log(this)
calls log undefined