461 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
1
answer
46
views
Why order of sloppy-mode function statement in block affects global variable differently?
snippet 1 -> output is "b"
if (true) {
x = "b";
function x() {}
}
console.log(x); //b
snippet 2 -> output is ƒ x() {}
if (true) {
function x() {}
x = "b";...
0
votes
0
answers
45
views
How can const work at the end of the code? [duplicate]
How come the const styles can be declared and initialized after being used in the code (in the App function) since in javascript they cannot be accessed before their declaration, resulting in a ...
-1
votes
2
answers
72
views
Any way to make a call to a class before it is declared?
I have the following code working but and it currently looks like this:
import { OtherClass } from "other-class"
class VeryLongClass {
}
OtherClass.run(VeryLongClass);
But I want it to ...
1
vote
0
answers
142
views
React Hooks Behavior: Difference When Using variables and states in useCallback before their Definition (ES5)
I have a doubt regarding, how hooks like useCallback() work when the variables, arrow functions, and states used in it and its dependency, are declared before and after the useCallback().
Note: The ...
0
votes
3
answers
726
views
How to pass a function that returns an object as a parameter to a composable?
I need a composable that needs to call a function from the viewmodel, and that function returns an instance of Airport object.
I did this:
@Composable
fun FlightsScreen(getAirportDetails: (String)->...
0
votes
1
answer
163
views
"ReferenceError: can't access lexical declaration 'BaseRepository' before initialization" on page refresh
I have a BaseRepository abstract class in my code which contains client instance and some general functions. The AuthRepository class inherits from BaseRepository. And I have an AuthService module ...
0
votes
2
answers
64
views
Index jumping out of for-loop with recursive method calling and || operator in Javascript
I am working with tree-like structure in Javascript, I found for-loop of Javascript works unexpected way. Let me describe it:
<html>
<head><head>
<body>
<script>
...
0
votes
0
answers
53
views
How to avoid hoisting state to an app-level?
I have an Android app in Jetpack Compose. I have a screen where the user can create a new player.
On this screen, the user can type in a Player name and select a color. Then, the user presses the ...
0
votes
2
answers
118
views
How to do state hoist of two or three levels?
Imagine a composable A that haves a lower composable B that haves a even lower composable C with haves some buttons.
The buttons must change a state remember variable stored in composable A. The state ...
0
votes
1
answer
80
views
Are modules fully "parsed" before they are used in other files?
I came across an example in React and I am trying to figure out how and why it works.
function MyComponent() {
return <h2>{name}</h2>
}
const name = "John";
export default ...
2
votes
2
answers
115
views
Hoisting, scope and function declaration [duplicate]
Here are the simple code:
{
function a() {}
a = "test";
}
console.log(a);
I expected to get "test" but got "ƒ a() {}" in console. Why is that? Can anyone explain ...
0
votes
2
answers
355
views
Why can I use arrow javascript function before its initialization [duplicate]
I checked out Why can I use a function before it's defined in JavaScript?. and It says I can use functions before or after initialization when using Declaration Functions. However for the case of ...
0
votes
1
answer
63
views
Different Uncaught ReferenceError for same situations
I don't understand why for these same situations console returns two different outputs
console.log(a);
let a = 1;
console says a is not defined
and here
function a1() {
console.log(a);
let a =...
user avatar
user22847503
0
votes
2
answers
290
views
Hoisting issue android Jetpack compose
I am new to Jetpack Compose and am having a problem with the hoisting topic. I have created a very basic app with a button, the app displays the amount of times you have clicked the button. I have ...
0
votes
0
answers
65
views
Why do these three JavaScript examples produce different outputs, considering function hoisting? [duplicate]
Question
I'm trying to understand why the following three JavaScript examples produce different outputs, even though they all seem to involve function hoisting. Shouldn't the outputs be the same based ...