setTimeout and V8
setTimeout and V8
我已经安装了V8单机版,并执行如下javascript代码:./d8 source.js
。当我使用setTimeout时,我会收到ReferenceError: setTimeout is not defined
。应该是这样吗?有可能以某种方式包含此功能吗?
setTimeout
不是ECMA-262的一部分,它是由浏览器实现的。但是,如果您安装Node.js(它是V8+额外的),您将获得一个命令行setTimeout
。
就其价值而言,V8现在(大约7.5年后)在其提供的外壳中有自己的setTimeout
。但它只需要一个参数(要调用的函数),并计划在当前作业完成后调用它,大致就像您将0
作为第二个参数传递给浏览器和Node.js提供的更熟悉的setTiemout
形式一样
因此给定example.js
:
console.log("a");
setTimeout(() => {
console.log("c");
}, 5000);
console.log("b");
然后
$v8 example.js
输出
一bc
而在CCD_ 9和CCD_。
(该示例使用jsvu安装的v8
命令,这至少是在V8中直接运行代码的一种方式。我认为d8
被包含在内…)
相关文章:
- Selenium WebDriver and JavaScript change
- PHP and Javascript functions
- Javascript Return and if/else
- SetTimeout and clearTimeout in Javascript
- lightbox in html 5 and javascript
- TimelineJS and AngularJS
- timeago.js with datatable and PHP
- javascript button ajax and php
- Ajax and Json with Rails
- Combine onload, onresize and onclick
- php布尔值's小写AND大写和数字布尔值'可以接受
- setTimeout and V8
- Jquery post and onclick
- Moment js and IOS
- V8或其他C++JavaScript解释器中的Continuations
- Rails 3.2 and Paloma gem
- Backbone, TypeScript, and super
- iframe and JavaScript on different pages
- Bing Maps V8 Web Control and CommonJS
- MobileFirst v8 and bootstrap Angular JS v1.5.3 error