<html ng-app='app' ng-controller='main' >
<head>
<meta charset="utf-8">
<meta name='viewport' content='width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0'>
<script src='jq/jquery-3.4.1.js'></script>
<style>
</style>
</head>
<body >
<script>
obj={uname:'jeff',age:18};
obj[Symbol.iterator]=function *fun()
{
yield 1
yield 2
yield 3
}
for(let i of obj)
{
console.log(i);//输出1、2、3
}
</script>
</body>
</html>
es6 设置Symbol.iterator接口遍历Generator函数内部状态
最新推荐文章于 2022-10-21 12:21:47 发布