Skip to content

Instantly share code, notes, and snippets.

@mooz
Created January 27, 2010 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mooz/287828 to your computer and use it in GitHub Desktop.
Save mooz/287828 to your computer and use it in GitHub Desktop.
let str = "";
let buffer = [];
for each (let c in str)
{
buffer.push(c);
}
window.alert(buffer.join(""));
// 以下のような文字列が返る。
// function (b) {
// return this.indexOf(b) == 0;
// }function (b) {
// var c = this.length - b.length;
// return c >= 0 && this.lastIndexOf(b, c) == c;
// }function () {
// for (var b = this, c = 0; c < arguments.length; c++) {
// b = b.replace(/\%s/, String(arguments[c]));
// }
// return b;
// }
buffer = [];
for (let [, c] in Iterator(str))
{
buffer.push(c);
}
window.alert(buffer.join(""));
// => 空文字が返る
String.prototype.google = function () "sucks";
for each (let c in "")
{
window.alert("for each => " + c);
}
// for each => function () "sucks"
for (let [, c] in Iterator(""))
{
window.alert("iter => ", c);
}
// window.alert は呼ばれない
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment