개발자의 노트
[javascript] jquery hashtable 사용하기

https://code.google.com/p/suas-map-server/source/browse/trunk/+suas-map-server/suas4/cssjs/lib/jquery/js/plugin/jQuery.Hashtable-1.1.js 특별한 설명은 필요없을 듯.. 사용법 해쉬테이블 생성 : var ht = new jQuery.Hashtable(); 키-값 추가 : ht.add("item1","hello"); 값 얻기 : var val = ht.get("item1"); 키 삭제 : ht.remove("item1"); 키가 있는지 여부 : ht.containsKey("item1"); 값이 있는지 여부 : ht.containsValue("hello"); 키나 값이 있는지 여부 : ht.contains..

Javascript에서 mongodb objectid 구하기

mongodb의 objectid에 대한 설명은 http://docs.mongodb.org/manual/reference/object-id/ 12byte의 길이를 가지며 507f1f77bcf86cd799439011 형식의 값을 가진다. 각 byte는 아래와 같이 구해진다. a 4-byte value representing the seconds since the Unix epoch,a 3-byte machine identifier,a 2-byte process id, anda 3-byte counter, starting with a random value. 자바스크립트 상에서 구현하기 위해 아래 사이트를 방문하자. https://github.com/justaprogrammer/ObjectId.js 이곳에서 ..

[Javascript] undefined/null 의 true/false 비교

특정 값이 undefined 인지를 체크하기 위해서는 var a; if (typeof a == "undefined") {} => true if (a == undefined) {} => true null 인지를 체크하기 위해서는 var b = null; if (b == null) {} => true 위와 같이 정확하게 값을 체크하는데 사용될 수 있다. 하지만, undefined와 null은 논리연산에서는 false로 처리되므로 아래처럼 간단하게 체크하면 되겠다. var a; if (a) {} => false if (!a) {} => true var b = null; if (b) {} => false if (!b) {} => true undefined와 null을 철저히 체크하는 경우가 아니라면, if (!..