> For the complete documentation index, see [llms.txt](https://yamoo9.gitbook.io/scss-mixins/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yamoo9.gitbook.io/scss-mixins/utilities/units/remove-unit.md).

# remove-unit()

## 용도

[rem()](/scss-mixins/utilities/units/rem.md), [em()](/scss-mixins/utilities/units/em.md) 함수 내부에서 사용되는 유틸리티 함수로 단위를 제거하는 데 사용합니다.

## 사용법 <a href="#usage" id="usage"></a>

단위를 제거할 값을 `remove-unit()` 함수에 전달하면 단위가 제거된 값을 반환합니다.

> remove-unit($value:**number**) → **number(unitless)**

```javascript
@debug remove-unit(100px);   // → 100 반환
@debug remove-unit(3.245em); // → 3.245 반환
@debug remove-unit(0.78rem); // → 0.78 반환
```

| 매개변수(parameter) | 유형(type) | 필수(required) | 기본 값(default) |
| :-------------: | :------: | :----------: | :-----------: |
|      $value     |  number  |      ✔︎      |               |

## 로직

`remove-unit()` 유틸리티는 다음의 로직에 의해 작성되었습니다.&#x20;

```javascript
@function remove-unit($value) {
  @return ($value / ($value * 0 + 1));
}
```

1. 단위가 포함된 숫자 유형의 값을 전달 받음
2. 값을 단위가 포함된 `1` 값으로 변경 (예: `120px` → `1px`)
3. 값을 동일한 단위의 `1` 로 나눠 단위를 상쇄 (예: `120px`/`1px` → `120`)

## 참고 <a href="#reference" id="reference"></a>

유틸리티 함수 로직에 사용된 Sass의 빌트인 모듈은 다음과 같습니다.

* [@function](https://sass-lang.com/documentation/at-rules/function)
