Fork me on GitHub
随笔 - 215  文章 - 13  trackbacks - 0
<2016年1月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456


专注即时通讯及网游服务端编程
------------------------------------
Openresty 官方模块
Openresty 标准模块(Opm)
Openresty 三方模块
------------------------------------
本博收藏大部分文章为转载,并在文章开头给出了原文出处,如有再转,敬请保留相关信息,这是大家对原创作者劳动成果的自觉尊重!!如为您带来不便,请于本博下留言,谢谢配合。

常用链接

留言簿(1)

随笔分类

随笔档案

相册

Awesome

Blog

Book

GitHub

Link

搜索

  •  

积分与排名

  • 积分 - 204249
  • 排名 - 127

最新评论

阅读排行榜

http://www.open-open.com/lib/view/open1350010424369.html
一个采用原生Go语言开发的JavaScript分析器和解释器。
// Create a new runtime
Otto := otto.New()
 
Otto.Run(`
    abc 
= 2 + 2
    console.log(
"The value of abc is " + abc)
    
// The value of abc is 4
`)
 
value, err :
= Otto.Get("abc")
{
    
// value is an int64 with a value of 4
    value, _ := value.ToInteger()
}

 
Otto.Set(
"def"11)
Otto.Run(`
    console.log(
"The value of def is " + def)
    
// The value of def is 11
`)
 
Otto.Set(
"xyzzy""Nothing happens.")
Otto.Run(`
    console.log(xyzzy.length) 
// 16
`)
 
value, _ 
= Otto.Run("xyzzy.length")
{
    
// value is an int64 with a value of 16
    value, _ := value.ToInteger()
}

 
value, err 
= Otto.Run("abcdefghijlmnopqrstuvwxyz.length")
if err != nil {
    
// err = ReferenceError: abcdefghijlmnopqrstuvwxyz is not defined
    
// If there is an error, then value.IsUndefined() is true
    
}

项目主页:
http://www.open-open.com/lib/view/home/1350010424369

robertkrimen / otto

Watch1890 Fork154

分支代码更新时间:2016-01-12

开发语言:Go

ZIP文件下载

 

posted on 2016-01-13 15:49 思月行云 阅读(1517) 评论(0)  编辑 收藏 引用 所属分类: Golang

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理