Open hmu332233 opened 2 years ago
종종 신입분들에게 드리던 문제 모음
5초 뒤에 숫자 3을 리턴하는 함수를 만들기
console에 찍힌 값과 그 이유는?
const strA = 'a';
const strB = 'a';
console.log(strA === strB);
const arrA = [];
const arrB = [];
console.log(arrA === arrB);
const promise1 = () => new Promise(resolve => {
console.log('promise1');
resolve(true);
});
const promise2 = () => new Promise(resolve => { console.log('promise2'); resolve(false); });
const promise1Results = await promise1(); const promise2Results = await promise2();
const results = false || promise1Results || promise2Results;
```js
const promise1 = () => new Promise(resolve => {
console.log('promise1');
resolve(true);
});
const promise2 = () => new Promise(resolve => {
console.log('promise2');
resolve(false);
});
const results = false || await promise1() || await promise2();
import React, { useState } from 'react';
export function App(props) { const [arr, setArr] = useState([ 1, 2, ])
const handleClick = () => { arr[0] = 3; setArr(arr); }
return (
); }
- console에 찍히는 값은?
```html
<html>
<body>
<script>
window.onload = function() {
var text = 'Hello!';
}
// 1번 문제
console.log(text);
// 2번 문제
setTimeout(() => {
console.log(text);
}, 1000);
</script>
</body>
</html>
Search Keyword 퀴즈, 신입