{"action":"created","issue":{"url":"https://api.github.com/repos/codecombat/codecombat/issues/2874","labels_url":"https://api.github.com/repos/codecombat/codecombat/issues/2874/labels{/name}","comments_url":"https://api.github.com/repos/codecombat/codecombat/issues/2874/comments","events_url":"https://api.github.com/repos/codecombat/codecombat/issues/2874/events","html_url":"https://github.com/codecombat/codecombat/issues/2874","id":91987242,"number":2874,"title":"[JavaScript] Can't use ES5 Array methods","user":{"login":"UltCombo","id":2090712,"avatar_url":"https://avatars.githubusercontent.com/u/2090712?v=3","gravatar_id":"","url":"https://api.github.com/users/UltCombo","html_url":"https://github.com/UltCombo","followers_url":"https://api.github.com/users/UltCombo/followers","following_url":"https://api.github.com/users/UltCombo/following{/other_user}","gists_url":"https://api.github.com/users/UltCombo/gists{/gist_id}","starred_url":"https://api.github.com/users/UltCombo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UltCombo/subscriptions","organizations_url":"https://api.github.com/users/UltCombo/orgs","repos_url":"https://api.github.com/users/UltCombo/repos","events_url":"https://api.github.com/users/UltCombo/events{/privacy}","received_events_url":"https://api.github.com/users/UltCombo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/codecombat/codecombat/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":23,"created_at":"2015-06-30T05:28:47Z","updated_at":"2015-10-14T00:07:48Z","closed_at":null,"body":"This sample code using ES5's [`Array#forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) does not seem to work:\r\n\r\n```js\r\nthis.findEnemies().forEach(function(enemy) {\r\n    this.say(enemy.type); // never runs\r\n}, this);\r\nthis.say('hello'); // runs\r\n```\r\n\r\nIt looks like the `forEach` is just being skipped.\r\n\r\nAlso, note that not providing a `thisArg` also results in the same behavior, e.g.:\r\n\r\n```js\r\nvar that = this;\r\nthis.findEnemies().forEach(function(enemy) {\r\n    that.say(enemy.type); // never runs\r\n});\r\nthis.say('hello'); // runs\r\n```\r\n\r\nIs this possibly an Aether bug?"},"comment":{"url":"https://api.github.com/repos/codecombat/codecombat/issues/comments/147888708","html_url":"https://github.com/codecombat/codecombat/issues/2874#issuecomment-147888708","issue_url":"https://api.github.com/repos/codecombat/codecombat/issues/2874","id":147888708,"user":{"login":"UltCombo","id":2090712,"avatar_url":"https://avatars.githubusercontent.com/u/2090712?v=3","gravatar_id":"","url":"https://api.github.com/users/UltCombo","html_url":"https://github.com/UltCombo","followers_url":"https://api.github.com/users/UltCombo/followers","following_url":"https://api.github.com/users/UltCombo/following{/other_user}","gists_url":"https://api.github.com/users/UltCombo/gists{/gist_id}","starred_url":"https://api.github.com/users/UltCombo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UltCombo/subscriptions","organizations_url":"https://api.github.com/users/UltCombo/orgs","repos_url":"https://api.github.com/users/UltCombo/repos","events_url":"https://api.github.com/users/UltCombo/events{/privacy}","received_events_url":"https://api.github.com/users/UltCombo/received_events","type":"User","site_admin":false},"created_at":"2015-10-14T00:07:48Z","updated_at":"2015-10-14T00:07:48Z","body":"Progress!\r\n\r\nAssignments whose RHS contains calls to built-in high-order functions whose callback contains call expression(s) now seem work properly. E.g.:\r\n\r\n```js\r\nfunction double(x) { return x * x; }\r\nvar arr = [1, 2, 3].map(function(n) { return double(n); });\r\n```\r\n\r\nI still have to fix the case when these are not part of assignment expressions, but they should be easier to handle now. These will use the same core logic, and their return value is not meaningful so they should be simpler to implement.\r\n\r\nA few issues that I ran into:\r\n\r\n- I could not find a way to access the `_aether` instance outside of the sandbox, is it possible to get a reference to it in the world worker? For now, I resorted to an ugly hack to get generators working.\r\n\r\n- Aether replaces the `constructor` prototype property, so it was harder to detect generatorified functions at runtime. I implemented another temporary ugly hack.\r\n\r\n- Objects cloned with Aether's `createAPIClone` lose custom prototypes (e.g. objects instantiated from non-built-in constructors). Is this a safety measure or a limitation of Aether?\r\n\r\nI'll work a bit more on this and hopefully submit a PR for feedback later tonight."}}