9
這可能嗎?例如:在JavaScript中檢測循環支持...
var parts = [1,2,3,4,5];
for (part of parts) {
console.debug(part);
}
我想檢測這樣做是否可能。
這可能嗎?例如:在JavaScript中檢測循環支持...
var parts = [1,2,3,4,5];
for (part of parts) {
console.debug(part);
}
我想檢測這樣做是否可能。
你總是可以試着去捕捉這些東西。但是你也需要eval
,因爲有些javascript引擎會提早釋放SyntaxError。
try {
eval("for (var i of []);");
console.log("yep");
} catch(ex) {
console.log("nope");
}
經過Firefox(「yep」)和Chrome(「nope」)的測試。
你很酷,兄弟。 –
另外,http://kangax.github.io/es5-compat-table/es6/。 [來源](https://github.com/kangax/es5-compat-table/blob/1b978c9403b281e3c6bbdbcee2b6f1eda561cd07/es6/index.html#L409-L417)。 –
如果您將鼠標懸停在@JonathanLonowski鏈接的表格中的(C)圖標上,它將顯示該功能的測試源。 –