-
나머지 연산자(%)JavaScript 2023. 5. 18. 11:34
나머지 연산자(%)
나머지 연산자(%)는 왼쪽 피연산자를 오른쪽 피연산자로 나눴을 때의 나머지를 구한다.
부호는 항상 왼쪽 피연산자의 부호를 따른다.
예시를 통해 알아보자
console.log(13 % 5); // Expected output: 3 console.log(-13 % 5); // Expected output: -3 console.log(4 % 2); // Expected output: 0 console.log(-4 % 2); // Expected output: -0'JavaScript' 카테고리의 다른 글
parseInt (0) 2023.05.22 Slice method (0) 2023.05.15