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 little bit contradictory with var functionName
Tag: eval
Why I see unsafe-eval alert when using setTimeout with strings?
Here is the example how it appear in Chrome dev tools: String Refused to evaluate a string as JavaScript because ‘unsafe-eval’ is not an allowed source ofscript in the following Content Security Policy directive: “script-src’self’ ‘unsafe-inline’ https:”. What does this alert means and what is the security concern of using setTimeout with strings? Answer You’re using setTimeout wrong. When you
Is there a safe way to run eval in a webpage and avoid it to access the content of the rest of the page?
I wonder if it is possible to run code provided by users in a webpage in a safe way. I would like to add code that users can dynamically change to change some of the page behaviour, but I donĀ“t want them to use exploits. For example, I would like to let the users write a method returning a boolean
discord.js eval command returning [object Map] and [object Object]
so I have my eval command, however when I run such things as an eval to set status or something like that, it returns either [object Object] or [object Map]. I have fixed the previous error with [object Promise], however Object and Map still occur. My code is below, if someone knows how to fix this that would be amazing.
javascript eval works one way but not the other, why?
I am trying to use eval function for dynamic assignment. I know it is bad practice and have modified the code to not use eval. Still though, I don’t understand why it worked one way but not the other. Here is what worked: What didn’t work: Can someone tell me what’s wrong with the second approach? Answer In the second
How to dynamically execute/eval JavaScript code that contains an ES6 module / requires some dependencies?
I want my users to be able to use JavaScript as a scripting language inside my JavaScript application. In order to do so, I need to dynamically execute the source code. There seem to be two main options for dynamically executing JavaScript: a) Use eval(…) method ( or var func = new Function(…);) . b) Add a <script> node to