[toc]
const object = { a: 1, b: 2, c: 3 };
for (const property in object) {
console.log(`${property}: ${object[property]}`);
}
// expected output:
// "a: 1"
// "b: 2"
// "c: 3"
const array1 = ['a', 'b', 'c'];
for (const element of array1) {
console.log(element);
}
// expected output: "a"
// expected output: "b"
// expected output: "c"
将代码的作用域设置到一个特定的对象中。 语法: with (expression) statement
var qs = location.search.substring(1)
var hostName = location.hostname
var url = location.href
with(location){
var qs = search.substring(1)
var hostName = hostname
var url = href
}