๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์„ ํ˜ธํ•˜๋Š”๊ฐœ๋ฐœ

javascript ๊ณต๋ฐฑ ๋ฐ null ์ฒดํฌ ๋ฉ”๋ชจ

javascript ๊ณต๋ฐฑ ๋ฐ null ์ฒดํฌ์ถ”๊ฐ€!!

์ž๋ฃŒํ˜•์— ์ƒ๊ด€์—†์ด ๊ฐ’์˜ ์กด์žฌ ์œ ๋ฌด ํ™•์ธ, true:์žˆ์Œ, false:์—†์Œ ([], {} ๋„ ๋นˆ๊ฐ’)

์•„๋ž˜๋Š” ์˜ˆ์ œ์ž…๋‹ˆ๋‹ค.

//์ž๋ฃŒํ˜•์— ์ƒ๊ด€์—†์ด ๊ฐ’์˜ ์กด์žฌ ์œ ๋ฌด ํ™•์ธ, true:์žˆ์Œ, false:์—†์Œ ([], {} ๋„ ๋นˆ๊ฐ’)
function isExist(val) {
	if (val == "" || val == null || val == undefined || val == "undefined" || (val != null && typeof val == "object" && !Object.keys(val).length)) {
		return false;
	} else {
		return true;
	}
}

var ckVal = $.cookie('CookieValue');	
if (isExist(ckVal)) {
	alert("์ฟ ํ‚ค๊ฐ’์ด ์กด์žฌํ•˜๋Š”๊ฒฝ์šฐ ์‹คํ–‰");
} else {
	alert("์ฟ ํ‚ค๊ฐ’์ด ์—†๋Š”๊ฒฝ์šฐ ์‹คํ–‰");
}

#javascript, #null์ฒดํฌ, #๋นˆ๊ฐ’์ฒดํฌ, #๋นˆ๊ฐ’, #undefined์ฒดํฌ, #exist