Linked Questions
10 questions linked to/from Why is a function declaration within a condition block hoisted to function scope in Chrome but not Firefox?
4
votes
1
answer
1k
views
hoisting behavior changed between chrome 48 and 49 ? [duplicate]
if (true) {
function test() {
console.log(true);
}
} else {
function test() {
console.log(false);
}
}
test()
Chrome 48 (and node <5.9.1) logs false, chrome 49 (and firefox) log ...
3
votes
1
answer
75
views
function expression on firefox - not expected result [duplicate]
if (true) {
function foo(){ return 1; }
}
else {
function foo(){ return 2; }
}
foo();
The above code is an example of function expression and returns 1 in Firefox 28 whereas 2 in Chrome ( expected ...
0
votes
0
answers
23
views
What is the definition of "scope" when we are talking about function hoisting in JavaScript [duplicate]
I am learning JavaScript Function Hoisting, which says "the declaration of functions are moved to the top of their scope". Then I read the definition of "scope" from this doc, it ...
71
votes
4
answers
36k
views
Are named functions preferred over anonymous functions in JavaScript? [duplicate]
Possible Duplicate:
JavaScript: var functionName = function() {} vs function functionName() {}
There are two possible methods for pulling out a function in Javascript:
var foo = function() { ... }...
28
votes
2
answers
1k
views
How does this hoisting work with block scope? [duplicate]
I've been asked about a question
{
function foo() {
console.log('A');
}
foo();
foo = 1;
function foo() {
console.log('B');
}
foo = 2;
console.log(foo);
}
...
6
votes
1
answer
602
views
Firefox: function hoisting error
I used to assume that functions always get hoisted to the top of any block of JavaScript code.
For example, this works:
document.addEventListener('something', dummy);
function dummy(){
console....
0
votes
3
answers
854
views
//Uncaught Error: Pick color is not a function - I can not find the Error
Everything was fine until I call the function var picked color = pickColor(); I have run the function pickColor() in console separately - works fine!!! Please help!!!
Html
<!DOCTYPE html>
<...
-1
votes
1
answer
113
views
In javascript, what are the "statement positions"? [closed]
I read in this article that function declarations can appear only in statement position. I'm wondering what are these "statement positions".
5
votes
1
answer
103
views
Scoping and closure oddities in javascript
This was presented yesterday at TC39. You can find the gist here:
var p = () => console.log(f);
{
p(); // undefined
console.log(f); // function f(){}
f = 1;
p(); // undefined
console....
-1
votes
1
answer
106
views
Javascript hoisting confusion [duplicate]
I read Kyle's I don't know JS and came to know that function declarations will hoist first before the var. So in the below code
<script>
foo();
var a = true;
if ( a ) {
...