분류
javascript
Javascript 30초 Snippet - Type : getType
본문
기본 유형의 값을 반환합니다.
https://github.com/30-seconds/30-seconds-of-code
값이 정의되지 않았거나 null 인 경우 소문자 생성자 이름 인 "undefined"또는 "null"을 반환합니다.
const getType = v => v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase();
ex)
getType(new Set([1, 2, 3])); // 'set'
- 이전글Javascript 30초 Snippet - Type : is 19.11.25
- 다음글Javascript 30초 Snippet - Date : yesterday 19.11.25