---
# System prepended metadata

title: Собеседование 2024-04-08

---

# Собеседование 2024-04-08

Дмитрий Шустов

```
### Как проверить переменную на объект?
let x;
const isObject = typeof x === 'object'

number
string
boolean
bigInt
object
undefined

### Какой порядок вывода в консоль?

console.log('start');

setTimeout(function() {
  console.log('setTimeout');
}, 0);

Promise.resolve().then(function() {
  console.log('promise1');
}).then(function() {
  console.log('promise2');
});

console.log('finish');

'start'
'finish'
promise1
promise2
setTimeout

### Чем плох код?

const obj = {};

function f (x) {
  setTimeout(
    () => { x.a = 'some'; },
    1000
  );
  
  return obj.a || x;
}

f(obj);

### UI


- order3.pdf
- order1.pdf

- common
  - rules.pdf
  - x.pdf
- favorite
  - rules.pdf
- important
  - order2.pdf
  - x.pdf

const categoryList = [
  { id: 'c1', name: 'common' },
  { id: 'c2', name: 'favorite' },
  { id: 'c3', name: 'important' },
];

const fileList = [
  { id: 'f1', name: 'rules.pdf', categoryList: ['c1', 'c2'] },
  { id: 'f2', name: 'order1.pdf', categoryList: [] },
  { id: 'f3', name: 'order2.pdf', categoryList: ['c3'] },
  { id: 'f4', name: 'order3.pdf', categoryList: [] },
  { id: 'f5', name: 'x.pdf', categoryList: ['c1', 'c3'] },
];


interface IReduce<C, F> {
    [k: ]: 
}

const App = () => {

    return 
    <div>
        <ul>
        {fileList.map((file) => {
            if (!file.categoryList.length) return <li key={file.id}>{file.name}</li>
            return null;
        }}
        </ul>
        <ul>
            {categoryList.map((category) => {
                return ( 
                    <li key={category.id}>
                        {category.name}
                        <ul>
                            {fileList.map((file) => {
                                if (file.categoryList.includes(category.id)) return <li key={file.id}>{file.name}</li>;
                                return null;
                            })}
                        </ul>
                    </li>
                );
            })}
        </ul>
    </div>
}


https://i.imgur.com/UJPisQ2.png


const a1b2 = { a: 1, b: 2 }

const keys = getKeys(a1b2) // ['a', 'b']: ('a' | 'b')[] 

type A1B2 = { a: 1, b: 2 }

type Result = GetKeys<A1B2> // ('a' | 'b')[]

type GetKeys<T> = {
    [key in keyof T]
}


```