-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f55f583
commit 2267152
Showing
20 changed files
with
413 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,7 +126,7 @@ | |
"id": 1 | ||
}, | ||
{ | ||
"bundle": "es5.1/language", | ||
"bundle": "es5/language", | ||
"id": 1 | ||
} | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,7 +83,7 @@ | |
"id": 1 | ||
}, | ||
{ | ||
"bundle": "es5.1/language", | ||
"bundle": "es5/language", | ||
"id": 1 | ||
} | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
{ | ||
"name": "ECMAScript 5", | ||
"nameSlug": "es5-katas", | ||
"items": [ | ||
{ | ||
"name": "`function.bind()`", | ||
"description": "The `bind()` method creates a new function with a given scope and optionally parameter(s).", | ||
"path": "function-api/bind", | ||
"level": "ADVANCED", | ||
"requiresKnowledgeFrom": [], | ||
"links": [ | ||
{ | ||
"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind", | ||
"comment": "The MDN docs about `bind()`.", | ||
"tags": [ | ||
"mdn", | ||
"docs" | ||
] | ||
}, | ||
{ | ||
"url": "https://262.ecma-international.org/5.1/#sec-15.3.4.5", | ||
"comment": "The ECMAScript Language Specification, 5 Edition, Section 15.3.4.5, when `bind()` was introduced.", | ||
"tags": [ | ||
"spec" | ||
] | ||
} | ||
], | ||
"groupName": "function API", | ||
"groupNameSlug": "function-api", | ||
"publishDateRfc822": "Mon, 16 Oct 2023 19:00:00 GMT", | ||
"id": 1 | ||
}, | ||
{ | ||
"name": "`function.length` (with ES5 features)", | ||
"description": "The `length` property indicates the number of parameters a function expects.", | ||
"path": "function-api/length", | ||
"level": "BEGINNER", | ||
"requiresKnowledgeFrom": [ | ||
{ | ||
"bundle": "es5/language", | ||
"id": 1 | ||
} | ||
], | ||
"links": [ | ||
{ | ||
"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length", | ||
"comment": "The MDN docs about `length`.", | ||
"tags": [ | ||
"mdn", | ||
"docs" | ||
] | ||
}, | ||
{ | ||
"url": "https://262.ecma-international.org/5.1/#sec-15.3.5.1", | ||
"comment": "The ECMAScript Language Specification, 5 Edition, Section 15.3.5.1.", | ||
"tags": [ | ||
"spec" | ||
] | ||
} | ||
], | ||
"groupName": "function API", | ||
"groupNameSlug": "function-api", | ||
"publishDateRfc822": "Wed, 18 Oct 2023 19:00:00 GMT", | ||
"id": 2 | ||
}, | ||
{ | ||
"name": "`function.arguments` (as modified since ES5)", | ||
"description": "The `arguments` property of a function is an object that contains all the arguments passed to the function.", | ||
"path": "function-api/arguments", | ||
"level": "BEGINNER", | ||
"requiresKnowledgeFrom": [], | ||
"links": [], | ||
"groupName": "function API", | ||
"groupNameSlug": "function-api", | ||
"id": 3 | ||
}, | ||
{ | ||
"name": "Turn strict mode on/off", | ||
"description": "The `use strict` directive indicates that the code should be executed in \"strict mode\", where you can for example not use undeclared variables.", | ||
"path": "strict-mode/on-off", | ||
"level": "ADVANCED", | ||
"requiresKnowledgeFrom": [ | ||
{ | ||
"bundle": "es1/language", | ||
"id": 15 | ||
} | ||
], | ||
"links": [ | ||
{ | ||
"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode", | ||
"comment": "The MDN docs about strict mode.", | ||
"tags": [ | ||
"mdn", | ||
"docs" | ||
] | ||
}, | ||
{ | ||
"url": "https://262.ecma-international.org/5.1/#sec-4.2.2", | ||
"comment": "Chapter 4.2.2 in the specification explains that and why ECMAScript offers a \"strict mode\" to restrict language features, and that it can coexist with non-strict code in the same program.", | ||
"tags": [ | ||
"spec" | ||
] | ||
}, | ||
{ | ||
"url": "https://262.ecma-international.org/5.1/#sec-10.1.1", | ||
"comment": "Chapter 10.1.1 in the specification explains how to turn strict mode on and off.", | ||
"tags": [ | ||
"spec" | ||
] | ||
}, | ||
{ | ||
"url": "https://262.ecma-international.org/5.1/#sec-C", | ||
"comment": "Appendix C \"The strict mode restriction and exceptions\" explains the differences between strict mode and non-strict mode in detail.", | ||
"tags": [ | ||
"spec" | ||
] | ||
} | ||
], | ||
"groupName": "Strict mode", | ||
"groupNameSlug": "strict-mode", | ||
"publishDateRfc822": "Mon, 16 Oct 2023 19:00:00 GMT", | ||
"id": 4 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
{ | ||
"name": "ECMAScript 5", | ||
"nameSlug": "es5-katas", | ||
"groups": { | ||
"function API": { | ||
"items": [ | ||
{ | ||
"name": "`function.bind()`", | ||
"description": "The `bind()` method creates a new function with a given scope and optionally parameter(s).", | ||
"path": "function-api/bind", | ||
"level": "ADVANCED", | ||
"requiresKnowledgeFrom": [], | ||
"publishDateUTC": "2023-10-16T19:00:00.000Z", | ||
"links": [ | ||
{ | ||
"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind", | ||
"comment": "The MDN docs about `bind()`.", | ||
"tags": [ | ||
"mdn", | ||
"docs" | ||
] | ||
}, | ||
{ | ||
"url": "https://262.ecma-international.org/5.1/#sec-15.3.4.5", | ||
"comment": "The ECMAScript Language Specification, 5 Edition, Section 15.3.4.5, when `bind()` was introduced.", | ||
"tags": [ | ||
"spec" | ||
] | ||
} | ||
], | ||
"groupName": "function API", | ||
"id": "1" | ||
}, | ||
{ | ||
"name": "`function.length` (with ES5 features)", | ||
"description": "The `length` property indicates the number of parameters a function expects.", | ||
"path": "function-api/length", | ||
"level": "BEGINNER", | ||
"requiresKnowledgeFrom": [ | ||
{ | ||
"bundle": "es5/language", | ||
"id": 1 | ||
} | ||
], | ||
"publishDateUTC": "2023-10-18T19:00:00.000Z", | ||
"links": [ | ||
{ | ||
"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length", | ||
"comment": "The MDN docs about `length`.", | ||
"tags": [ | ||
"mdn", | ||
"docs" | ||
] | ||
}, | ||
{ | ||
"url": "https://262.ecma-international.org/5.1/#sec-15.3.5.1", | ||
"comment": "The ECMAScript Language Specification, 5 Edition, Section 15.3.5.1.", | ||
"tags": [ | ||
"spec" | ||
] | ||
} | ||
], | ||
"groupName": "function API", | ||
"id": "2" | ||
}, | ||
{ | ||
"name": "`function.arguments` (as modified since ES5)", | ||
"description": "The `arguments` property of a function is an object that contains all the arguments passed to the function.", | ||
"path": "function-api/arguments", | ||
"level": "BEGINNER", | ||
"requiresKnowledgeFrom": [], | ||
"links": [], | ||
"groupName": "function API", | ||
"id": "3" | ||
} | ||
], | ||
"slug": "function-api", | ||
"name": "function API" | ||
}, | ||
"Strict mode": { | ||
"items": [ | ||
{ | ||
"name": "Turn strict mode on/off", | ||
"description": "The `use strict` directive indicates that the code should be executed in \"strict mode\", where you can for example not use undeclared variables.", | ||
"path": "strict-mode/on-off", | ||
"level": "ADVANCED", | ||
"requiresKnowledgeFrom": [ | ||
{ | ||
"bundle": "es1/language", | ||
"id": 15 | ||
} | ||
], | ||
"publishDateUTC": "2023-10-16T19:00:00.000Z", | ||
"links": [ | ||
{ | ||
"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode", | ||
"comment": "The MDN docs about strict mode.", | ||
"tags": [ | ||
"mdn", | ||
"docs" | ||
] | ||
}, | ||
{ | ||
"url": "https://262.ecma-international.org/5.1/#sec-4.2.2", | ||
"comment": "Chapter 4.2.2 in the specification explains that and why ECMAScript offers a \"strict mode\" to restrict language features, and that it can coexist with non-strict code in the same program.", | ||
"tags": [ | ||
"spec" | ||
] | ||
}, | ||
{ | ||
"url": "https://262.ecma-international.org/5.1/#sec-10.1.1", | ||
"comment": "Chapter 10.1.1 in the specification explains how to turn strict mode on and off.", | ||
"tags": [ | ||
"spec" | ||
] | ||
}, | ||
{ | ||
"url": "https://262.ecma-international.org/5.1/#sec-C", | ||
"comment": "Appendix C \"The strict mode restriction and exceptions\" explains the differences between strict mode and non-strict mode in detail.", | ||
"tags": [ | ||
"spec" | ||
] | ||
} | ||
], | ||
"groupName": "Strict mode", | ||
"id": "4" | ||
} | ||
], | ||
"slug": "strict-mode", | ||
"name": "Strict mode" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
describe('The `arguments` prop - discouraged since 1997 (and might not work)', () => { | ||
// it('WHEN accessing `arguments` in strict mode THEN the JS throws', () => { | ||
// const fn = function() {} | ||
// assert.throws(() => fn.arguments); | ||
// }); | ||
// it('WHEN accessing `arguments` inside a function, in strict mode THEN the JS throws', () => { | ||
// const fn = function() { | ||
// return arguments; | ||
// } | ||
// // assert.deepEqual(Object.getOwnPropertyDescriptors(fn()), {}); | ||
// }); | ||
// it('WHEN reading `arguments` using an Object-method THEN it returns `undefined`', () => { | ||
// const fn = function() {} | ||
// assert.equal(Object.getOwnPropertyDescriptor(fn, 'arguments'), undefined); | ||
// }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
describe('Using `fn.bind()` creates a new function with scope (and parameters) pre-configured', () => { | ||
describe('GIVEN we bind a scope to a function', () => { | ||
it('WHEN we call the bound function with a custom object THEN the scope of `this` refers to the given object', () => { | ||
const fn = function() { | ||
return this.newVariable; | ||
}; | ||
const boundFn = fn.____({myScopeVariable: 'forty-two'}); | ||
assert.strictEqual(boundFn(), 'forty-two'); | ||
}); | ||
it('WHEN binding a string to String\'s `toUpperCase` THEN calling the resulting function returns the upper case value of the string', () => { | ||
const yell = String.prototype.toUpperCase('hello'); | ||
assert.strictEqual(yell(), 'HELLO'); | ||
}); | ||
it('WHEN binding Array\'s `slice()` method THEN array-like values can dynamically be converted to an array', () => { | ||
const arrayLike = {length: 1, 0: 'a'}; | ||
const toArray = function (a) { return Array.prototype.bind(a)(); }; | ||
assert.deepStrictEqual(toArray(arrayLike), ['a']); | ||
}); | ||
}); | ||
describe('GIVEN we bind parameters to a function', () => { | ||
it('WHEN binding the first parameter of a function THEN the bound function can be called just with the seconds parameter', () => { | ||
const add = function(a, b) { return a + b; }; | ||
const add5 = add.bind(); | ||
assert.strictEqual(add5(10), 15); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
describe('The property `function.length` indicates the number of parameters a function expects', () => { | ||
describe('GIVEN we read the `length` from a bound function', () => { | ||
it('WHEN binding a function with 3 parameters THEN the bound value has still a `length` of 3', () => { | ||
const fn = function(a, b, c) {}; | ||
const boundFn = fn.____(null); | ||
assert.equal(boundFn.length, 3); | ||
}); | ||
it('WHEN binding a function (that expects three parameters) with one parameter THEN the `length` will reduced by 1, it will be 2', () => { | ||
const fn = function(a, b, c) {}; | ||
const boundFn = fn.bind(null, 1, 2, 3); | ||
assert.equal(boundFn.length, 2); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.