Skip to content

Executable coding blocks production-readiness - PR 2 #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 57 commits into from
Mar 9, 2025
Merged
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
3b0f7b6
exec: how-do-you-convert-a-string-to-a-number-in-javascript
tahachm Mar 1, 2025
df35cdd
exec: what-are-the-various-data-types-in-javascript
tahachm Mar 2, 2025
8278bc1
exec: explain-the-concept-of-hoisting-with-regards-to-functions
tahachm Mar 2, 2025
66da940
exec: explain-the-difference-in-hoisting-between-var-let-and-const
tahachm Mar 2, 2025
377fded
exec: what-is-the-spread-operator-and-how-is-it-used
tahachm Mar 2, 2025
03d6fcd
exec: how-do-you-check-the-data-type-of-a-variable
tahachm Mar 2, 2025
c036438
exec: what-are-the-differences-between-variables-created-using-let-va…
tahachm Mar 2, 2025
d6f3b0e
exec: whats-the-difference-between-a-variable-that-is-null-undefined-…
tahachm Mar 2, 2025
15d0f04
exec: what-are-template-literals-and-how-are-they-used
tahachm Mar 2, 2025
e3f2fe4
exec: how-can-you-avoid-problems-related-to-hoisting
tahachm Mar 2, 2025
c976667
exec: what-is-the-difference-between-double-equal-and-triple-equal
tahachm Mar 2, 2025
f9b6c18
exec: what-language-constructs-do-you-use-for-iterating-over-object-p…
tahachm Mar 2, 2025
1a59dbd
exec: what-is-the-purpose-of-the-break-and-continue-statements
tahachm Mar 2, 2025
93fc6c7
exec: what-is-the-ternary-operator-and-how-is-it-used
tahachm Mar 2, 2025
52b9eb3
exec: how-do-you-access-the-index-of-an-element-in-an-array-during-it…
tahachm Mar 2, 2025
3e044c8
exec: what-is-the-purpose-of-the-switch-statement
tahachm Mar 2, 2025
5917f8d
exec: what-are-rest-parameters-and-how-are-they-used
tahachm Mar 2, 2025
b3b8e22
exec: explain-the-concept-of-the-spread-operator-and-its-uses
tahachm Mar 2, 2025
f0f1c01
[auto] regenerate table of contents
github-actions[bot] Mar 2, 2025
be56334
exec: what-are-the-benefits-of-using-spread-syntax-and-how-is-it-diff…
tahachm Mar 6, 2025
f61faa7
exec: explain-the-differences-on-the-usage-of-foo-between-function-fo…
tahachm Mar 6, 2025
730aee9
exec: what-is-the-difference-between-a-parameter-and-an-argument
tahachm Mar 6, 2025
7cf0b24
exec: whats-the-difference-between-call-and-apply
tahachm Mar 6, 2025
40c09e4
partial fix: can-you-offer-a-use-case-for-the-new-arrow-function-synt…
tahachm Mar 6, 2025
1b56553
exec: difference-between-function-person-var-person-person-and-var-pe…
tahachm Mar 6, 2025
86aabc6
partial fix: what-is-the-definition-of-a-higher-order-function
tahachm Mar 6, 2025
d837bb0
exec: what-is-recursion-and-how-is-it-used-in-javascript
tahachm Mar 6, 2025
f8a5f10
exec: what-are-default-parameters-and-how-are-they-used
tahachm Mar 6, 2025
75b98d6
exec: what-are-the-various-ways-to-create-objects-in-javascript
tahachm Mar 6, 2025
9d624e4
exec: explain-the-difference-between-dot-notation-and-bracket-notatio…
tahachm Mar 6, 2025
08881bc
exec: what-are-the-different-methods-for-iterating-over-an-array
tahachm Mar 6, 2025
a758de0
exec: how-do-you-add-remove-and-update-elements-in-an-array
tahachm Mar 6, 2025
c945e2b
partial fix: what-are-the-different-ways-to-copy-an-object-or-an-array
tahachm Mar 6, 2025
a7b0bbc
exec: explain-the-difference-between-shallow-copy-and-deep-copy
tahachm Mar 6, 2025
7e7cfb0
exec: what-are-the-advantages-of-using-the-spread-operator-with-array…
tahachm Mar 6, 2025
5f53908
exec: how-do-you-check-if-an-object-has-a-specific-property
tahachm Mar 6, 2025
4b75530
exec: explain-the-concept-of-destructuring-assignment-for-objects-and…
tahachm Mar 6, 2025
0983882
exec: how-do-you-reliably-determine-whether-an-object-is-empty
tahachm Mar 6, 2025
8a7e7f1
partial fix: explain-the-concept-of-a-callback-function-in-asynchrono…
tahachm Mar 6, 2025
b961378
partial fix: what-are-promises-and-how-do-they-work
tahachm Mar 6, 2025
6bc474a
partial fix: what-are-callback-functions-and-how-are-they-used
tahachm Mar 6, 2025
4235698
partial fix: explain-the-difference-between-synchronous-and-asynchron…
tahachm Mar 6, 2025
9c4464c
exec: explain-how-prototypal-inheritance-works
tahachm Mar 7, 2025
3656d64
exec: explain-the-difference-between-classical-inheritance-and-protot…
tahachm Mar 7, 2025
38f2a07
exec: explain-the-concept-of-inheritance-in-es2015-classes
tahachm Mar 7, 2025
7a1b2be
exec: what-is-the-purpose-of-the-new-keyword
tahachm Mar 7, 2025
4b864fa
exec: how-do-you-create-a-constructor-function
tahachm Mar 7, 2025
208848a
exec: what-are-the-differences-between-es6-class-and-es5-function-con…
tahachm Mar 7, 2025
ed92473
exec: explain-the-concept-of-lexical-scoping
tahachm Mar 7, 2025
ec00257
exec: explain-the-concept-of-scope-in-javascript
tahachm Mar 7, 2025
aca5590
exec: how-can-closures-be-used-to-create-private-variables
tahachm Mar 7, 2025
14f54cf
exec: explain-the-difference-between-global-scope-function-scope-and-…
tahachm Mar 7, 2025
0596b5c
partial fix: what-advantage-is-there-for-using-the-arrow-syntax-for-a…
tahachm Mar 7, 2025
9925c12
[auto] regenerate table of contents
github-actions[bot] Mar 7, 2025
f0a6605
Merge branch 'main' into taha/executable-coding-blocks-2
yangshun Mar 9, 2025
b5fcd8c
Update en-US.mdx
yangshun Mar 9, 2025
3fcfe79
[auto] regenerate table of contents
github-actions[bot] Mar 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The main advantage of using an arrow function as a method inside a constructor i

For example, let's say we have a `Person` constructor that takes a first name as an argument has two methods to `console.log()` that name, one as a regular function and one as an arrow function:

```js
```js live
const Person = function (name) {
this.name = name;
this.sayName1 = function () {
Expand Down Expand Up @@ -68,12 +68,14 @@ const myFunction = (arg1, arg2, ...argN) => expression;

### Examples

```js
```js live
// Arrow function with parameters
const multiply = (x, y) => x * y;
console.log(multiply(2, 3)); // Output: 6

// Arrow function with no parameters
const sayHello = () => 'Hello, World!';
console.log(sayHello()); // Output: 'Hello, World!'
```

### Advantages
Expand All @@ -86,7 +88,7 @@ const sayHello = () => 'Hello, World!';

Arrow functions cannot be used as constructors and will throw an error when used with the `new` keyword.

```js
```js live
const Foo = () => {};
const foo = new Foo(); // TypeError: Foo is not a constructor
```
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for console.log(arguments), the lexical scope of our runCode functions is being inherited, and thus the TypeError is not being thrown. Rather, we just get an empty object {} which are the empty arguments of our runCode function simply. Therefore, have left this codeblock unexecutable. Any ideas? I tried using globalThis but that would mess with other examples then

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can leave it

Expand All @@ -104,7 +106,7 @@ arrowFunction(1, 2, 3);

Since arrow functions do not have their own `this`, they are not suitable for defining methods in an object. Traditional function expressions or function declarations should be used instead.

```js
```js live
const obj = {
value: 42,
getValue: () => this.value, // `this` does not refer to `obj`
Expand All @@ -119,7 +121,7 @@ One of the most notable features of arrow functions is their behavior with `this

### Arrow functions inside function constructors

```js
```js live
const Person = function (name) {
this.name = name;
this.sayName1 = function () {
Expand Down