This is the 11th day of my participation in Gwen Challenge

Hello everyone, I am @always_positive, a blogger who studies hard and insists on dreams. I hope to learn and make progress together with you.

126. Output what?

function getFine(speed, amount) {
  const formattedSpeed = new Intl.NumberFormat({
    'en-US',
    { style: 'unit'.unit: 'mile-per-hour' }
  }).format(speed)

  const formattedAmount = new Intl.NumberFormat({
    'en-US',
    { style: 'currency'.currency: 'USD' }
  }).format(amount)

  return `The driver drove ${formattedSpeed} and has to pay ${formattedAmount}`
}

console.log(getFine(130.300))
Copy the code

A) Intl.NumberFormat B) Intl.NumberFormat C) Intl.

127. Output what?

const spookyItems = ["👻"."🎃"."🕸"];
({ item: spookyItems[3]} = {item: "💀" });

console.log(spookyItems);
Copy the code

A) array B) array C) array D) array

128. What is output?

const name = "Lydia Hallie";
const age = 21;

console.log(Number.isNaN(name));
console.log(Number.isNaN(age));

console.log(isNaN(name));
console.log(isNaN(age));
Copy the code

The Number. IsNaN API is the same as the Number. IsNaN API is the same as the Number.

129. Output what?

const randomValue = 21;

function getInfo() {
	console.log(typeof randomValue);
	const randomValue = "Lydia Hallie";
}

getInfo();
Copy the code

D) a call to a block-level scope created by const where the variable declaration is promoted but not initialized generates a temporary dead zone and an error is reported.

130. Output what?

const myPromise = Promise.resolve("Woah some cool data");

(async() = > {try {
		console.log(await myPromise);
	} catch {
		throw new Error(`Oops didn't work`);
	} finally {
		console.log("Oh finally!");
	}
})();
Copy the code

A) async B) await C) await D) await

131. Output what?

const emojis = ["🥑"["✨"."✨"["🍕"."🍕"]]];

console.log(emojis.flat(1));
Copy the code

Flat (1) can be used to reduce the dimension of an array by removing the one-dimensional array.B.

132. What output?

class Counter {
	constructor() {
		this.count = 0;
	}

	increment() {
		this.count++; }}const counterOne = new Counter();
counterOne.increment();
counterOne.increment();

const counterTwo = counterOne;
counterTwo.increment();

console.log(counterOne.count);
Copy the code

D) The sum of three is equal to the sum of three.

133. Output what?

const myPromise = Promise.resolve(Promise.resolve("Promise!"));

function funcOne() {
	myPromise.then(res= > res).then(res= > console.log(res));
	setTimeout(() = > console.log("Timeout!"), 0);
	console.log("Last line!");
}

async function funcTwo() {
	const res = await myPromise;
	console.log(await res);
	setTimeout(() = > console.log("Timeout!"), 0);
	console.log("Last line!");
}

funcOne();
funcTwo();
Copy the code

A: D) call the stack to execute the synchronous code in the first function, then microtask the Promise, and then start executing the second function because of the await keyword. The function will wait until the Promise state becomes Resolved before it can proceed with the synchronization code, so print the Promise, execute the synchronization code Last line, and when the call stack is empty, execute the two macro tasks setTimeout, 1 and 2.

134. How to call the sum method in sum.js in index.js?

// sum.js
export default function sum(x) {
	return x + x;
}

// index.js
import * as sum from "./sum";
Copy the code

C) import a default exposure function with import *. D) import a default exposure function with import *.

135. Output what?

const handler = {
	set: () = > console.log("Added a new property!"),
	get: () = > console.log("Accessed a property!")};const person = new Proxy({}, handler);

person.name = "Lydia";
person.name;
Copy the code

A: C, this is mainly to check our familiarity with Proxy object usage. Through this API, we can add custom behavior to the object. When setting the value of the object, the set method will be called, and when calling the object, the GET method will be called.

Title source

Github.com/lydiahallie…