출처 : http://www.phpschool.com/link/tipntech/74034
<script type='text/javascript'>
// 조사 판별
String.prototype.postposition = function(str1, str2) {
return this + ((this.charCodeAt(this.length - 1) - 0xAC00) % 28 ? str1 : str2);
};
var word1 = '배';
var word2 = '도시락';
alert('오늘도 ' +word1.postposition('이', '가')+ ' 고파서 ' +word2.postposition('을', '를')+ ' 까먹었다.');
</script>