나의 성장과정  
Front Page
Tag | Location | Media | Guestbook | Admin   
 
[javascript] null 과 undefined 차이
 <script type="text/javascript">
  window.onload = function () {
 
        var i;
        alert(document.getElementById('bora'));                 // null
        alert(typeof(document.getElementById('bora')));     //object
        alert(document.getElementById('boram').value);     //  빈값
        alert(i);                                                             //undefined
   
       if(document.getElementById('bora')) {
         alert('true');
       }else {
          alert('false');                       //실행
      }
  }
 </script>

<body>
 <input type="text" id="boram" />
</body>

먼저 " null " 은 변수를 초기화 시키거나 어떤 값이나 이벤트를 지울 때 사용되어지는  아무런 값도 없는 것이며,

                      null값은 스트링 연산에 대해서는 "null",

                      논리 연산에서는 false,

                      수치 연산에서는 0으로 각각 변환되어집니다..

두번째로 " undefined " 는 변수만 만들고, 값을 할당하지 않은 상태를 말합니다..!!


결론은 undefined null 에 포함되지 않습니다!!                                      

출처 


BLOG main image
Simple is beatiful!
 Notice
 Category
분류 전체보기 (755)
전직 (0)
일상 (7)
진행중 (6)
3Fs (14)
미정 (3)
Serendipitous! (6)
지르자 : 맥북 (5)
(5)
FaceBook (3)
 TAGS
primitive Eclipse CP1215 tomcat laserjet Safari JavaScript DOM URL URLConnection Debug 접근지정자 사파리 네트워크 커피 HP Java 자바스크립트 JS color
 Calendar
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
 Recent Entries
 Recent Comments
 Archive
 Link Site
상상할 수 있는 힘이 ..
즐겁게살자
인생의 소중한 꿈
{fly to the ocean.com}
누노의 컴퓨토피아
한RSS
[지인]I can\'t stop. Love. Lo…
[원츄]OK 괜찮아 다 잘 될거야
[원츄]애자일 이야기
[원츄]IBM Developerworks
 Visitor Statistics
Total :
Today :
Yesterday :
rss