Questions tagged [javascript-engine]

For questions related to JavaScript engine development. If you are simply referring to issues with JavaScript code, use the [javascript] tag instead.

171 questions
1
vote
1 answer

What is the order of execution in a JavaScript 'for' loop?

This post is kind of a simplified version of this post: What is the exact order of execution of Javascript's for loop? I'm super interested in why I keep getting confused while working with for loops. I'd like to learn how a for loop is executed…
mttvlk
  • 33
  • 1
  • 1
  • 11
1
vote
0 answers

Is a decimal digit after the '\' symbol in string allowed in ECMA-262 strict mode?

According to the 6th edition of the ECMA-262 specification in strict mode in single or double quoted strings after '\' it is possible to have EscapeSequence or LineTerminatorSequence and EscapeSequence must be one of the following:…
1
vote
1 answer

What is Javascript atomic execution unit for events?

The Javascript engine is executing a function which in turn calls another function (sequentially) and this goes on for say 5s. Meanwhile, several events were triggered either by the user or programmatically. Can we take for granted that no event…
1
vote
1 answer

how exactly does eval() keyword break compiler optimizations in javascript

function func1(str) { eval(str); newVar = 100; function func2() { console.log(bar); console.log(newVar); } func2(); } func1("bar = 42;"); I've read that the eval() keyword should be avoiding because it cheats the lexical scope…
noi.m
  • 3,070
  • 5
  • 34
  • 57
1
vote
1 answer

"document" is not defined in java ScriptEngine

i'm trying to call document in java using scriptEngine here is my code ScriptEngineManager scriptEngineManager=new ScriptEngineManager(); ScriptEngine scriptEngine=scriptEngineManager.getEngineByName("nashorn"); …
DoctorDo
  • 331
  • 2
  • 6
  • 15
1
vote
1 answer

FATAL EXCEPTION NoClassDefFoundError

in Android I want to execute a script. So I added the JavaScript engine from http://www.java2s.com/Code/JarDownload/jsr223/jsr223.jar.zip My gradle (Module: app) says: dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') …
sampa
  • 535
  • 4
  • 27
1
vote
0 answers

Is that possible to call native keypress and mouse move from Chrome App/Extension

Like java.awt.Robot or RobotJS does. Once again, I need actually move mouse and hit keys from Chrome app/extension (not just plain web site, know that's impossible)?
1
vote
1 answer

Nashorn and 'with' context passed from Java

I am struggling with nashorn and with block. I would like to pass 'context' from java with HashMap and use it in my code. However, I am not able to get this working. JS to be evaluated with(ctx) { return a+b; } Java map to be…
svobol13
  • 1,842
  • 3
  • 25
  • 40
1
vote
0 answers

ScriptEngine returns 5 when asked questions the doubles

I use the code below to make my scriptEngine. It worked fine until I tried to do calculations containing doubles. The code below should return 30 but instead returns 5. Am I doing something wrong or can the scriptEngine just not do doubles? String…
Maiko Kingma
  • 929
  • 3
  • 14
  • 29
1
vote
0 answers

Java 7 Rhino-based JavaScript ScriptEngine set system property "rhino.opt.level"

The java documentation about the JavaScript ScriptEngine implementation says, that it is possible to set the system property "rhino.opt.level" if there is no security manager active. ("When security manager is not used, System property…
Kazuo
  • 387
  • 5
  • 12
1
vote
2 answers

Java ScriptEngine - Create dynamic variables in java class

I've using the java ScriptEngine to execute a script that could alter a shared Java class. I'm wondering, if it's possible to support dynamically created variables in the java class? // create a script engine manager ScriptEngineManager factory =…
webber
  • 1,834
  • 5
  • 24
  • 56
1
vote
0 answers

ScriptEngineManager not passing binded variables?

I was trying to bind a variable but the javascript engine is saying there is no method getRow() on my java object which I do have so I don't get why this code does not work context.getRow() in the javascript is the issue. public static void…
Dean Hiller
  • 19,235
  • 25
  • 129
  • 212
1
vote
2 answers

Javascript engines and virtual machines similaraties?

this is a very simple question that i cannot seem to find answers for: Are javascript engines such as chromes V8 and Internet Explorers Chakra (in EI9+) similar in function to virtual machines for languages such as Java?
1
vote
5 answers

Scope resolution in Javascript using 'with' keyword

There seems to be a strange behavior in Javascript with hoisting and scoping , when using 'with' keyword. I understand the usage of 'with' is considered taboo, but came across this in one of the frameworks and had to deal with it. But…
sbr
  • 4,735
  • 5
  • 43
  • 49
1
vote
3 answers

How to convert type Object from engine.eval to type int

My program takes a String input and calculates it using engine.eval() from ScriptEngine imports. How do I convert the evaluated value to type int? import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import…
Marco Lau
  • 579
  • 2
  • 10
  • 25