block by shreshthmohan 343767e6b929df282bb0ae97a9a02451

Global - Execution Context, Object // source http://jsbin.com/casasuc

Full Screen

index.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Global - Execution Context, Object</title>
</head>
<body>
<p>Look in the console.</p>
  <p><a href="https://stackoverflow.com/questions/34838659/the-this-keyword-behaves-differently-in-nodejs-and-browser" target="_blank"><b>this</b> behaves diffrently in the browser vs Node.js</a></p>
<script id="jsbin-javascript">
console.log(this);
console.log(this === window);
console.log('The base/global execution constant creates two things, a global object (objects are simply name value pairs, remember?) and *this*. this is also equal to the global object. Inside the broswer window is the global object.')
if (this === window) {
  console.log('this is same a window object');
  
}
console.log('There would be a different window/global object in another browser window. Each tab is a different execution context and so it would have it\'s own global/window object.');

</script>



<script id="jsbin-source-javascript" type="text/javascript">console.log(this);
console.log(this === window);
console.log('The base/global execution constant creates two things, a global object (objects are simply name value pairs, remember?) and *this*. this is also equal to the global object. Inside the broswer window is the global object.')
if (this === window) {
  console.log('this is same a window object');
  
}
console.log('There would be a different window/global object in another browser window. Each tab is a different execution context and so it would have it\'s own global/window object.');
</script></body>
</html>

jsbin.casasuc.js

console.log(this);
console.log(this === window);
console.log('The base/global execution constant creates two things, a global object (objects are simply name value pairs, remember?) and *this*. this is also equal to the global object. Inside the broswer window is the global object.')
if (this === window) {
  console.log('this is same a window object');
  
}
console.log('There would be a different window/global object in another browser window. Each tab is a different execution context and so it would have it\'s own global/window object.');