DynJSECMAScript 运行环境

联合创作 · 2023-09-27 23:48

DynJS 是一个在 JVM 上实现的 ECMAScript 运行环境。

示例代码:

$ wget -q -O dynjs-0.2.0.zip http://bit.ly/dynjs-020-download
$ unzip dynjs-0.2.0.zip
$ ./bin/dynjs --console
DynJS console.
Type exit and press ENTER to leave.
dynjs> var x = {}
dynjs> x.name = "Douglas"
dynjs> var speak = function(name) { print(name); }
dynjs> speak(x.name)
Douglas
$ cat my_app.js
print("Hi! What's your name?");
var sayHello = function(name) {
    print("Hello " + name);
}

System = java.lang.System;
scanner = new java.util.Scanner(System.in);
name = scanner.nextLine();
sayHello(name);

$ ./bin/dynjs my_app.js
Hi! What's your name?
Douglas
Hello Douglas
^D
浏览 8
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报