Questions tagged [executioncontext]

Refers to concept of an environment where code is evaluated and executed. This refers to global and function execution contexts, how control is switched between, how binding occurs in context etc.

Execution context is abstract concept of programming and is closely related to executing code itself and order how it will executed (execution stack), how pointers to objects are created and used and how they're divided from each other. Because of abstract nature of concept itself Execution context is closely tied to particular implementation in programming languages (Javascript for example). Check related tags

Resources

Related tags

196 questions
0
votes
0 answers

scope vs variable environment in execution context

What is the difference between scope and variable environment in the execution context of Javascript? Why do they need scope when they already have a variable environment?
0
votes
0 answers

When is a function's lexical scope created in Javascript?

Is function's lexical scope created in "compile time" of that function's area(if that function is declared in the global area, this area is the global area), or "evaluation time" of that function, or "execution time" of that function? Which of…
vriznet
  • 3
  • 3
0
votes
1 answer

Why is variable undefined in global object even though it has not been defined?

I have this code: console.log(apple); If I run the program, I get the following result: console.log(apple); ^ ReferenceError: apple is not defined This is what I expected, but if I modify the code to print the apple variable from the…
sam
  • 43
  • 1
  • 2
  • 7
0
votes
1 answer

Execution Context with "Console.log()"

As far as I understand, "execution context" is determined by where a function is called — not where it is declared. So in the example below I would expect this.name to evaluate to undefined. Thus I'm not sure how console.log() has access to the this…
bugsyb
  • 5,662
  • 7
  • 31
  • 47
0
votes
2 answers

Is 'global' a function in Javascript?

I am studying hard what the closure is in Javascript. According to MDN, closures are created every time a function is created, at function creation time. However, many articles and answers in Stack Overflow says that the concept of closure needs the…
vriznet
  • 3
  • 3
0
votes
2 answers

How to find the prototype object of a Class?

Learning about classes, prototypes etc. and it's finally all coming into place for me (which is quite exciting to say the least :))) However, my question has to do with finding the object prototype of a Class, where I should in theory find the its…
Vayl
  • 69
  • 1
  • 10
0
votes
0 answers

Error in shadowing a let variable with a var variable inside a block in Javascript

I have heard about shadowing in JS. My question is why can't we shadow a let variable present in global scope with a var variable present inside a block . Eg-> let a =100; { var a =100; console.log(a); } Output:-Uncaught SyntaxError: Identifier…
0
votes
0 answers

Do variable declaration with let and const in JavaScript work differently in block scope and global scope?

Here are two examples: console.log(x); let x = 4; throws Reference Error x is not defined; { console.log(y); let y = 3; } throws Reference Error Cannot access 'y' before initialization; So, my question is: why JS engine interprets these two cases…
J Sha
  • 15
  • 5
0
votes
2 answers

How to access the property from method defined in the same object javascript

I have defined a function which returns object which has property and a method. using the returned object I am calling the method inside the object to get the value of the property in the object. but I didn't received what I expected. function…
prem_kumar
  • 124
  • 1
  • 10
0
votes
0 answers

In JS Engine, does the IIFE's execution context get created & exited BEFORE or AFTER the variable declaration?

Since all IIFEs are function expressions, like a function declaration, does JavaScript allocate memory BEFOREHAND(before running any code) for a function expression that is lexically inside the global execution context? If yes, since functions get…
0
votes
1 answer

How do I get the Data in Nodejs from another Execution Context

I would like to take data from a website whenever it is changed. For this case I use MutateObservable. As scraper I use Puppeteer because the data is changed every second. And for this I need a permanently open browser I think. As server I use…
0
votes
0 answers

Lexical environment vs Scope vs Execution context in JavaScript

What the difference between all of these concepts? As I understood and become confused: Scope — This is where our variables, functions, and expressions are created and available. Lexical environment — it is an object with all of the variables,…
0
votes
0 answers

I'd like to ask 'Block scope' about 'for'

let arr = [] for (let i = 0; i < 3; i++) { arr.push(function() { console.log(i) }) } arr[0]() arr[1]() arr[2]() As far as I know, the function inside the block refers to its lexical environment. In this case, it will refer to i of block…
kwonryul
  • 481
  • 3
  • 10
0
votes
1 answer

Does a JavaScript-function can be seen as an execution context respectively as this?

In the lower example, why does the function outer which is assigned as method to the object-property with the identifier meth does not have an execution context which would be the this in the inner-function? Since the function outer assigned to meth…
quizmaster987
  • 549
  • 1
  • 6
  • 15
0
votes
1 answer

JavaScript: Execution context when a function reference is stored in an array

Consider the following code: var obj = { name: 'Hans', print: function(p) { console.log(this.name) } }; obj.print(); // prints 'Hans' We know that print function is called on object obj. In other words obj is (part of) the…
Hans
  • 2,674
  • 4
  • 25
  • 48