JavaScript 의 두 기호 연산 에 대한 상세 한 설명

파도

var i = 5.1;
var j = 5.5;
console.log(~~i); // 5
console.log(~~j); // 5
역할 유사Math.floor.
비슷 한 뜻 은 정 수 를 처리 할 때 음 수 를 처리 하면 둘 이 다르다 는 것 이다.

~~-5.1 // 5
Math.floor(-5.1) // -6
~~-5.5 // 5
Math.floor(-5.5) // -6
주:

Math.ceil(x)
Returns the smallest integer greater than or equal to a number.
Math.floor(x)
Returns the largest integer less than or equal to a number.
~~
  0  ,   0  
느낌표

var a = 1;
var b = null;
var c = '';
var d = 'code';
console.log(!!a); // true
console.log(!!b); // false
console.log(!!c); // false
console.log(!!d); // true
Boolean 과 유사 하 게 값 을 boolean 값 으로 변환 합 니 다.
총결산
이상 은 이 글 의 전체 내용 입 니 다.본 논문 의 내용 이 여러분 의 학습 이나 업무 에 어느 정도 도움 이 되 기 를 바 랍 니 다.궁금 한 점 이 있 으 시 면 댓 글 을 남 겨 주 셔 서 저희 에 대한 지지 에 감 사 드 립 니 다.

좋은 웹페이지 즐겨찾기