All Questions

7664
votes
88answers
1140492 views

How do JavaScript closures work?

A PHP Error was encountered

Severity: Notice

Message: Undefined index: body

Filename: views/Tagged_view.php

Line Number: 87

Backtrace:

File: /home/admin/web/allinonescript.com/public_html/application/views/Tagged_view.php
Line: 87
Function: _error_handler

File: /home/admin/web/allinonescript.com/public_html/application/controllers/Questions.php
Line: 158
Function: view

File: /home/admin/web/allinonescript.com/public_html/index.php
Line: 297
Function: require_once

1541
votes
22answers
401256 views

What is the scope of variables in JavaScript?

What is the scope of variables in javascript? Do they have the same scope inside as opposed to outside a function? Or does it even matter? Also, where are the variables stored if they are defined glob...
111
votes
3answers
28889 views

Reference: What is variable scope, which variables are accessible from where and what are "undefined variable" errors?

Note: This is a reference question for dealing with variable scope in PHP. Please close any of the many questions fitting this pattern as duplicate of this one. What is "variable scope" in PHP? A...
311
votes
7answers
179148 views

Short Description of the Scoping Rules?

What exactly are the Python scoping rules? If I have some code: code1 class Foo: code2 def spam..... code3 for code4..: code5 x() Where is x found? Some possible c...
303
votes
2answers
151610 views

How to choose the right bean scope?

I noticed that there are different bean scopes like: @RequestScoped @ViewScoped @FlowScoped @SessionScoped @ApplicationScoped What is the purpose of each? How do I choose a proper scope for my bean...
2132
votes
18answers
2225559 views

Using global variables in a function other than the one that created them

If I create a global variable in one function, how can I use that variable in another function? Do I need to store the global variable in a local variable of the function which needs its access?
408
votes
15answers
113877 views

How do I access previous promise results in a .then() chain?

I have restructured my code to promises, and built a wonderful long flat promise chain, consisting of multiple .then() callbacks. In the end I want to return some composite value, and need to access m...
2454
votes
21answers
537972 views

What's the difference between using "let" and "var" to declare a variable?

ECMAScript 6 introduced the let statement. I've heard it described as a "local" variable, but I'm still not quite sure how it behaves differently than the var keyword. What are the differences? When ...
26
votes
6answers
5959 views

Javascript: Do I need to put this.var for every variable in an object?

In C++, the language I'm most comfortable with, usually one declares an object like this: class foo { public: int bar; int getBar() { return bar; } } Calling getBar() works fine (ignoring t...
80
votes
3answers
6547 views

Local variables in Python nested functions

Okay, bear with me on this, I know it's going to look horribly convoluted, but please help me understand what's happening. from functools import partial class Cage(object): def __init__(self, an...

Previous Next