빈 객체를 체크 하는 방법은 다음과 같다.

var obj = {};
Object.keys(obj).length === 0 && JSON.stringify(obj) === JSON.stringify({});

$.isEmptyObject(obj); // JQuery
[참고] http://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object
function foo(a)
{
	a = typeof a !== 'undefined' ? a : 1;

	//code!
}

무한 스크롤은 다음과 같이 구현 하면 된다.

$(window).scroll(function () { 
   if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) {
    //code!
   }
});

자바 스크립트로 unicode 인코딩 과 디코딩은 다음과 같이 하면 된다.

function decodeUnicode(unicodeString) {
	var r = /\\u([\d\w]{4})/gi;
	unicodeString = unicodeString.replace(r, function (match, grp) {
	    return String.fromCharCode(parseInt(grp, 16)); } );
	return unescape(unicodeString);
}


function encodeUnicode(convertString) {
	var unicodeString = '';
	for (var i=0; i < convertString.length; i++) {
		var theUnicode = convertString.charCodeAt(i).toString(16).toUpperCase();

		while (theUnicode.length < 4) {
			theUnicode = '0' + theUnicode;
		}

		theUnicode = '\\u' + theUnicode;
		unicodeString += theUnicode;
	}

	return unicodeString;
}

encodeUnicode("김초보");
decodeUnicode("\uAE40\uCD08\uBCF4");

결과는

\uAE40\uCD08\uBCF4
김초보

이다.

+ Recent posts