A long list of (advanced) JavaScript questions, and their explanations :sparkles:
MIT License
51955
1223
7344

The answer says setInterval is an arrow function so thus bound to the config object.the callback function still holds a reference to the config object.
But for my test, ‘this’ points to the global Window object. The config object will be recycled.
This is my test ,use FinalizationRegistry
image

This code will output:
Promise {: 'I made it'}

The getData function is an async function that returns a resolved promise with the value 'I made it!'. The await operator is used to wait for the promise to be resolved before returning the resolved value.

why did you choose Promise {}

Perhaps may be useful to node that now it is possible to import modules on demand the ES modules way with dynamic import, aka import(). Documentation reference: MDN.

I've researched some information on this, the MDN states:

Every object in JavaScript has a built-in property, which is called its prototype. The prototype is itself an object, so the prototype will have its own prototype, making what's called a prototype chain. The chain ends when we reach a prototype that has null for its own prototype.

My understanding is that every object has a prototype and the last one in the chain has null for its value. I couldn't find any information on the "base object". I'd suggest that perhaps the answer may be incorrect.

Hello @lydiahallie,
Great job first of all. While going through the QA i found little correction. The answer of 37 is correct but the order of element is wrong.
Given: [1, 2, 3, 7 x empty, 11]
Correct: [1, 2, 3, empty x 7, 11]
Sharing the screenshot for more clarity.
Screenshot 2022-08-07 at 4 09 25 AM

I will fix it. Sending PR soon.
Happy Learning.
Regards,
Rajan

image

In this question console.log is missing due to which nothing would be printed. But the answer it is showing as A which is incorrect.

Output of the code is -> 4 5 6 and 15, because we invoked the add function which returns the sum value.

The last line in the answer's explanation, "There is no value radius on that object, which returns NaN" could probably be the following for more clarity-

"There is no value radius on that object, which returns undefined, which when multiplied by Math.PI returns NaN."

  1. What's the output?
    const shape = {
    radius: 10,
    diameter() {
    return this.radius * 2;
    },
    perimeter: () => 2 * Math.PI * this.radius,
    };

console.log(shape.diameter());
console.log(shape.perimeter());

A: 20 and 62.83185307179586
B: 20 and NaN
C: 20 and 63
D: NaN and 63

Answer: B
Note that the value of diameter is a regular function, whereas the value of perimeter is an arrow function.

With arrow functions, the this keyword refers to its current surrounding scope, unlike regular functions! This means that when we call perimeter, it doesn't refer to the shape object, but to its surrounding scope (window for example).

There is no value radius on that object, which returns NaN.

sorry guys, someone know the answer for this questionnarie?

For loops allow you to repeatedly run a block of code a certain number of
times. This for loop logs to the console ten times:

 for (let i = 0; i < 10; i++) {  
   // log the numbers 0 through 9  
   console.log(i)  
 }  

The first part, let i = 0, is run once at the beginning of the loop. The
variable i is used to track how many times the loop has run.

The second part, i < 10, is checked at the beginning of every loop
iteration before running the code inside the loop. If the statement is
true, the code inside the loop is executed. If it is false, then the loop
is complete. The statement i < 10; indicates that the loop will continue
as long as i is less than 10.

The final part, i++, is executed at the end of every loop. This increases
the variable i by 1 after each loop. Once i reaches 10, the loop will
exit.

The challenge:

Create a file named for-loop.js.

In that file define a variable named total and make it equal the number 0.

Define a second variable named limit and make it equal the number 10.

Create a for loop with a variable i starting at 0 and increasing by 1 each
time through the loop. The loop should run as long as i is less than
limit.

On each iteration of the loop, add the number i to the total variable. To
do this, you can use this statement:

 total += i  

When this statement is used in a for loop, it can also be known as an
accumulator. Think of it like a cash register's running total while each
item is scanned and added up. For this challenge, you have 10 items and
they just happen to be increasing in price by 1 each item (with the first
item free!).

After the for loop, use console.log() to print the total variable to the
terminal.

Check to see if your program is correct by running this command:

 javascripting verify for-loop.js  

There are lots of links pointing to https://www.theavocoder.com/
But seems the links do not work anymore as the website is private

答案描述有点问题,不完全是因为箭头函数,就算是换成普通函数也是一样的结果。

could you prepare more detail such as examples about question 14?

Hi, how could I help to translate in Italian language this amazing work?

I can't present full translation at once. So make me a collabrator. I will translate one by one.

I will raise a pr with the Hindi translation. You can assign this to me.

Lets consider the following screenshot:
image
image

Even after the control reaches the let assignment statement, the previous imports are undefined. Could anyone explain why is that so?
Also the following shows that the bundled internal variables are defined though:
image
image
Why does this behavior exist in javascript? Is this expected or something different.
Its in mozilla firefox browser (95.0.1)