I am learning about objects and their scopes, I got confused and decided to make a D&D pathfinder character sheet for practice. I made the character sheet as an object, child objects for ability scores, strength/dexterity/intelligence/etc… and then base and modifier values. in D&D you use your b…
Tag: scope
Reset an array and have it be mutable again
I am making tic-tac-toe from TOP, I’m not looking for someone to do my homework I just think I’m severely misunderstanding arrays, and or scope. I have a module “Game” where I store the game info It is all controlled from a controller module, that sets up the players, plays the round, …
Eval a function definition vs. variable function definition
If we define a function f() { … } in eval(…), why isn’t it available for the rest of the code, such as #button3’s onclick? As a comparison, if we define the function as f = () => { … };, then it is available for #button3’s onclick. Why this difference, which seems a litt…
Function parameter is not defined in callback
I am trying to get the location of the user and using that I am trying to get the city. I don’t why but when I call the query function, the city parameter is having some value but it is not reflected in the callback function’s if condition. However, if I replace the city variable in the If conditi…
How can I assign forEach to variable? Its possible?
Hello everyone:) I’m trying to write rock, paper, scissors game but I have a little problem. Is there any option to assign let playerChoice = buttons.forEach… to any variable as I did in this code? Unfortunately, it doesn’t work like this. I attached my code below. Thanks for any tips! Answe…
How does variable setting work with await?
Can someone explain to me why this is not working the way I am expecting? I am expecting the last console.log to run after my functions run, but it is returning empty length string instead of the actual date. These are the variables I want to set after my function call. Declaring them now so the scope is set …
Only in Safari: ReferenceError Can’t find variable
Many of my scripts look like this: They work fine on Chrome, Firefox, Edge and Opera but on Safari I get the error: Workaround If I declare the constants before the if statement the code works… …but I don’t understand why and I don’t what to make the constant globally available. Maybe …
I cant look for a value in a object array, it returns me error [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 1 y…
Why do I need this. keyword to reference a variable with the same name?
Good evening, This is my first post on stack overflow. I’m a newbie in programming and I can do many things in C++ – a language I love. However, recently I’ve moved on to javascript with the mission of getting hired. I’m creating a snake game and I’m automatizing its moves. I jus…
How to always make “this” keyword to reference the parent class (bind child methods to parent class)?
here is the simplest form of my problem: I know I can fn.bind(service1) in the mapper function to solve the problem, but as fn is dynamic, I would prefer not to do that. I have tried searching on how to get the parent class from child method but get no results. I want mapper to be able to call a