2019/06/17(2)
-
Javascript에서 null과 undefined 체크 방법
다른 동료가 코드 리뷰 도중에 null 체크를 굳이 해야하는지, undefined만 체크하는 것으로 충분하지 않은지 의견을 내었다. 사실 이 둘은 다르게 넘어올 수있기 때문에 번거롭더라도 null과 undefined를 모두 체크하는 것 좋지만, 다수의 변수값을 한번에 체크할 때는 코드가 지저분해지는 문제가 있을 수 있다. 그래서 찾아보니 다음과 같은 아주 좋은 방법이 있다. 물론 0이 넘어오지 않는 경우에만 해당될 듯. https://stackoverflow.com/questions/2559318/how-to-check-for-an-undefined-or-null-variable-in-javascript How to check for an undefined or null variable in JavaSc..
2019.06.17 -
Python에서 버전 비교 로직
http://codingdojang.com/scode/493 코딩도장 프로그래밍 문제풀이를 통해서 코딩 실력을 수련 codingdojang.com from itertools import zip_longest def compare(left, right): left_vars = map(int, left.split('.')) right_vars = map(int, right.split('.')) for a, b in zip_longest(left_vars, right_vars, fillvalue = 0): if a > b: return '>' elif a
2019.06.17