hmu332233 / tips

https://tips.minung.dev
1 stars 0 forks source link

quiz #34

Open hmu332233 opened 2 years ago

hmu332233 commented 2 years ago

Search Keyword 퀴즈, 신입

hmu332233 commented 2 years ago

종종 신입분들에게 드리던 문제 모음

const strA = 'a';
const strB = 'a';
console.log(strA === strB);

const arrA = [];
const arrB = [];
console.log(arrA === arrB);

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();

export function App(props) { const [arr, setArr] = useState([ 1, 2, ])

const handleClick = () => { arr[0] = 3; setArr(arr); }

return (

    {arr.map(v => (
  • {v}
  • ))}

); }


- console에 찍히는 값은?
```html
<html>
  <body>
       <script>
         window.onload = function() {
           var text = 'Hello!';
         }

         // 1번 문제
         console.log(text);

         // 2번 문제
         setTimeout(() => {
           console.log(text);
         }, 1000);
     </script>
  </body>
</html>