add array comprehension this and arguments tests

This commit is contained in:
Sebastian McKenzie 2014-10-13 03:29:50 +11:00
parent b18d1a79f4
commit 91dd5c67a4
4 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,5 @@
function add() {
return [for (i of [1, 2, 3]) i * arguments[0]];
}
add(5);

View File

@ -0,0 +1,8 @@
function add() {
var _arguments = arguments;
return [1, 2, 3].map(function () {
return i * _arguments[0];
});
}
add(5);

View File

@ -0,0 +1,5 @@
function add() {
return [for (i of [1, 2, 3]) i * this.multiplier];
}
add.call({ multiplier: 5 });

View File

@ -0,0 +1,8 @@
function add() {
var _this = this;
return [1, 2, 3].map(function () {
return i * _this.multiplier;
});
}
add.call({ multiplier: 5 });