- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这个关于 ECMAScript 规范(ECMA-262 第 8 版)的问题
这些天,我对作业和作业队列有点困惑。
这里有一些问题。
1:在ECMA-262中,有两种作业队列。一个是 ScriptJobs,另一个是 PromiseJobs。那么,女巫一号有偏好吗?
2:在ECMA-262中,仅定义了RunJobs
抽象操作。我想知道 RunJobs
执行的时间和地点?
3.我在FF 60中执行了blow代码。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
window.addEventListener('DOMContentLoaded', () => {
let x = document.createElement('script');
x.innerHTML = 'console.log(3);';
console.log('script start');
document.body.appendChild(x);
setTimeout(() => console.log(1), 0);
Promise.resolve(2).then(console.log);
console.log('script is end');
});
</script>
</head>
<body>
</body>
</html>
它记录:
script start
3
script end
2
1
为什么 script
元素在动态创建的执行上下文上执行?
c. Let nextQueue be a non‐empty Job Queue chosen in an implementation‐defined manner. If all Job Queues are empty, the result is implementation‐defined.
从 ECMA-262 RunJobs fork 。HTML 规范如何定义实现定义的方式?
@Bergi 像这样吗? PromiseJobs : [] , ScriptJobs : []
ScriptJobs.push(something);
// pop and run by Event loop
// blow will happens while `something` runs
PromiseJobs.push(anotherOne);
ScriptJobs.push(theother);
//end of `something`
//and in here, PromiseJobs will pop?
最佳答案
Which one have preference?
都不是。规范states “该规范没有定义多个作业队列的服务顺序。”队列只是一个工具,用于指定每个队列按 FIFO 顺序执行作业.
I want to know when and where the
RunJobs
execute?
这在很大程度上取决于实现。在像 Node.js 这样的环境中,它将在进程启动时被调用 - 这是基本的事件循环公式。当然会有更多的作业队列,例如用于定时器或异步IO操作。
Why script element execute on execution context that created dynamically?
因为 HTML 规范很奇怪。看看https://www.html5rocks.com/en/tutorials/speed/script-loading/或load and execute order of scripts以获得概述。详情可见 HTML5 processing model for script elements ,基本上就是这样
src
属性并且是经典脚本(不是模块)并且未插入解析器,是的,这使浏览器的 ECMAScript 队列模型完全失效。 Integration with the JavaScript job queue 部分也明确说明了这一点.
关于javascript - ECMAScript : Some questions about Job and Job queue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50373175/
Alexa 技能适用于第一个问题,但不适用于第二个问题。这是一个使用以下数组的困惑字母测验 var arr = [{"Q":"dcha","A":"chad"},{"Q":"goto","A":"to
我正在制作一个小问答 ios 应用程序。我希望第一个问题是随机的。我的代码如下。 let allQuestions = QuestionBank() var pickedAnswer : Bool =
我对 Dialogflow 比较陌生,我正在尝试创建一个医疗保健诊断语音聊天机器人,其工作方式如下。 用户体验 用户调用系统并受到聊天机器人的欢迎。 聊天机器人开始询问与分流相关的问题(例如,“您有慢
我正在尝试将一个表单(包含测试问题)提交到一个名为 Questions 的 mongo 集合中。我已经引用了运行服务器端代码的文件,我认为它应该都可以正常工作。这是我的代码: //add.html
import 'dart:async'; import 'question.dart'; import 'package:http/http.dart' as http; import 'dart:c
我想添加用户输入到列表中的任何字符串 run :- write('How many students you have: '),read(x),nl. enterNameOfStuden
我正在努力提高我的 JAVA 水平。现在我有一个关于线程的问题我不明白。 我尝试的代码是这样的, public class MyThread implements Runnable { pri
我正在为一个项目构建一个 XML 反序列化器,我经常遇到这种类型的代码情况: var myVariable = ParseNDecimal(xml.Element("myElement")) == n
我有一个 JSF 页面,它将创建一个新的 Comment。我将该页面的托管 bean 设为 RequestScoped 托管 bean。 @ManagedBean(name="PostComment"
房间和应用程序之间存在一对一的关系,意味着应用程序必须占用一个房间。如果我想获取未被应用占用的房间,如何写sql查询 最佳答案 select * from room r where not exist
我有一个 css 布局,其中我有一个单页网站 问题是我不想要滚动条所以我确实隐藏了溢出并且它工作正常但是当有不同的屏幕分辨率时,所以底部的内容被切断有没有办法解决这个问题 我的意思是,当内容适合首页时
我做了一个简单的算法,用于将整数转换为二进制,并将二进制作为字符串返回。目前,这些位被添加到列表的前面。在每一步连接字符串而不是附加到列表会更有效(就时间或空间而言)吗?为什么/为什么不? def t
我经常听说 mongodb 可以在一个集合级别执行原子性。您知道为什么以及如何将其与分片联系起来吗? replication 和 replicasets 之间的唯一区别是两者都是主/从(主要/次要),
我有几个关于线程的问题。能否请您澄清一下。 假设进程有一个或多个线程。如果进程被抢占/挂起,线程是否也被抢占或线程是否继续运行? 当挂起的进程被重新调度时,进程线程是否也被调度了?如果进程有进程有多个
我最近接受了一次采访,他问我单例设计模式是如何实现的,我告诉他使用静态变量和静态方法我们可以实现单例设计模式。 他似乎对答案满意但我想知道 我们可以有多少种不同的方式实现单例设计模式在 Java 中?
我以前使用 has_and_belongs_to_many,并已转换为 has_many :through。下面是它如何查找可以有很多用户玩的游戏列表。有了这个,我可以做 game.users 和 u
这是我的代码的骨架: var myArray: (Array | null); if (cnd) { myArray = []; myArray?.push(elt); // Question
使用ORLite时放置sqlite_unicode设置的正确位置在哪里? 最佳答案 不幸的是,没有一个真正好的地方。请参阅bug #61191: Enable sqllite_unicode in t
我承认我已经有一段时间没有使用 Perl 了,但这让我很难过。 这是问题: #!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); use DBI; pr
我有一个名为 Question 的模型。模型允许用户创建新问题。我正在尝试使用对象查询集填充多个表单。当我尝试使用查询集进行初始化时,会出现问题。我收到此错误 'Question' object i
我是一名优秀的程序员,十分优秀!