English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript null empty value

 JavaScript 전역 속성/함수

null valueindicating the intentional absence of any object value.

It is JavaScript'sOne of the primitive types.

The null value is not an identifier of a global object property, such as undefined. On the contrary, null indicates the absence of an identifier, indicating that the variable does not point to any object.

Syntax:

null
var str;
if (str == null) {
   // str is null
} else {
   // str is not null
}
테스트를 보세요‹/›

The difference between null and undefined

The values of null and undefined are equal, but the types are different.

When checking null or undefined, please note the difference between equals (==) and identity (===) operators, because the former performs type conversion.

typeof null  // "object" (due to legacy reasons, it is not "null")
typeof undefined // "undefined"
null == undefined// true
null === undefined   // false
테스트를 보세요‹/›

브라우저 호환성

모든 브라우저는 null 값을 완벽히 지원합니다:

null

기술 세부 사항

JavaScript 버전:ECMAScript 1

더 많은 예제

주어진 문자열이 [aeiou] 문자를 포함하지 않으면 getVowels() 함수는 0을 반환합니다:

function getVowels(str) {
   var x = str.match(/[aeiou]/gi);
   if (x === null) {
      return 0;
   }
   return x.length;
}
테스트를 보세요‹/›

 JavaScript 전역 속성/함수