JavaScript&Platform/JavaScript
[JavaScript] object 유무 체크 undefined null typeof
비니미니파파
2013. 9. 12. 11:11
object 유무 체크 #1
undefined
console.log( typeof objName ); // 결과 undefined
// objName 체크
if ( typeof objName != "undefined" ) {
}
체크 #2
console.log( document.getElementById("objName") ); // 결과 null
// objName 체크
if ( document.getElementById("objName") != null ) {
}