console
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>IERunES</title>
</head>
<body>
<h3>IE 浏览器运行 ECMAScript 最新版本代码</h3>
<ol>
<li>npm 依赖</li>
<code>
npm install --save core-js-bundle regenerator-runtime babel-standalone
</code>
<xmp>
<script nomodule src="/node_modules/core-js-bundle/minified.js"></script>
<script src="/node_modules/regenerator-runtime/runtime.js"></script>
<script src="/node_modules/babel-standalone/babel.min.js"></script>
</xmp>
<li>cdn 依赖</li>
<xmp>
<script nomodule src="https://unpkg.com/core-js-bundle/minified.js"></script>
<script src="https://unpkg.com/regenerator-runtime/runtime.js"></script>
<script src="https://unpkg.com/babel-standalone/babel.min.js"></script>
</xmp>
<li>编写代码</li>
<xmp>
<script type="text/babel" data-presets="latest,stage-0">
</script>
</xmp>
</ol>
<script nomodule src="https://unpkg.com/core-js-bundle/minified.js"></script>
<script src="https://unpkg.com/regenerator-runtime/runtime.js"></script>
<script src="https://unpkg.com/babel-standalone/babel.min.js"></script>
<script type="text/babel" data-presets="latest,stage-0">
const arr1 = [1, 2, 3]
const arr2 = [...arr1]
console.log(arr2);
let arr3 = arr2.map((x) => x * 2)
console.log(arr3);
const [x, y, z] = [[...arr3]]
console.log(x);
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
toString() {
return '(' + this.x + ', ' + this.y + ')';
}
}
console.log(new Point(1, 2).toString());
console.log(new Promise(function () {
}))
function getUser() {
return new Promise((resolve) => {
setTimeout(() => {
resolve('lzy')
}, 2000)
})
}
async function getUserName() {
let userName = await getUser()
console.log(userName)
}
getUserName()
</script>
</body>
</html>