Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

Empty Values

An empty value is distinct from undefined.

An empty string has a valid value and a defined type.

Example

let car = “”;
typeof car;

Null

In JavaScript, null represents “nothing” and is intended to signify the absence of existence.

However, in JavaScript, the data type of null is an object.

You can clear an object by assigning it a value of null.

Example

// Create an Object
let person = {firstName:“John”, lastName:“Doe”, age:50, eyeColor:“blue”};

person = null;
// Now value is null, but type is still an object

You can also clear an object by assigning it the value of undefined.

Example

let person = {firstName:“John”, lastName:“Doe”, age:50, eyeColor:“blue”};

person = undefined;
// Now both value and type is undefined

Difference Between Undefined and Null

You can also clear an object by assigning it the value of undefined.

typeof undefined      // undefined
typeof null           // object

null === undefined    // false
null == undefined     // true