DONATE  
MENU
JAVASCRIPT
AJAX
HTML
JSON

JavaScript Tutorials

INTRODUCTION

» Introduction to JavaScript

» Practice IT Editor

» JavaScript Example

» JavaScript Placement

» JavaScript Syntax

» JavaScript Statements

» JavaScript Input

» JavaScript Output

» JavaScript Comments

» JavaScript Variables

» Variables' Scope

» JavaScript Operators

» JS Expressions & Concatenation

» JavaScript Data Type

» JavaScript Numbers

» Number Object

» JavaScript Strings

» String Object

» JavaScript Booleans

» Boolean Object

» JavaScript Functions

» JavaScript Arrays

» Array Object - Properties

» Array Object - Methods

» JavaScript Objects

» JavaScript Undefined

» JavaScript Nulls

CONDITIONAL TESTING

» If Statement

» If Else Statement

» JavaScript Ternary Operator

» Switch Statement

LOOPS

» For Loops

» While Loops

» Break & Continue

» For...In Loops

» do...while Loop

FUNCTIONS

» JavaScript Functions

» Creating Functions

» Functions' Parameters

» Functions' Arguments

» Function Invocation

» The Return Keyword

» The Arguments Object

» Callback Functions

» Arrow Functions

ARRAYS

» JavaScript Arrays

» Creating Arrays

» Accessing Arrays

» Looping Arrays

» Multi - dimensional Arrays

OBJECTS

» JavaScript Objects

» Creating Objects

» Prototype Definition

» Accessing Objects

» The this Keyword

AJAX

» Introduction to AJAX

JSON

» Introduction to JSON

JAVASCRIPT DATES

» The Date Object

» Date Methods

» Timing (SetInterval & SetTimeout)

MATH OBJECT

» Math Object

» Math Methods

HTML / JS DOM

» DOM Introduction

» Accessing HTML Elements in DOM

» Get And Change Elements' Contents & Values

» Change Styling - DOM CSS

» DOM Attributes

» JavaScript Event Listeners

» DOM Event Listeners

» JS Events

MISCELLANEOUS

» JS Strict Mode

» JavaScript Hoisting

» JavaScript let keyword

» Reserved Keywords

» JS Best Practices

» JavaScript vs ECMAScript

JAVASCRIPT EXAMPLES

» JavaScript Calculator

.. » JavaScript » Introduction » JavaScript Nulls
Share Tweet WhatsApp

JavaScript Nulls

Null is a JavaScript data type that can be assign to a variable to depict the absence of a value for that variable. When assigned to a variable, it means no value is available yet for that variable. Difference Between Null & Undefined The difference between null and undefined can be a bit confusing since both depict variables without values but then, the difference between undefined and null is, JavaScript automatically assigns the value and data type of undefined to any variable being used without a value or a variable being used which was neither declared nor assigned a value. On the other hand, null is assigned to a variable by us to denote the absence of a value for that variable. It is not automatically assigned by JavaScript rather we assign it just the way we assign numbers and string. We assign null to show we are aware of the existence of the variable without a value for it.
var x = null;
We also use null to remove or offset the value of a variable if we no longer need that value.
var arr = [1, 2, 3]; //arr contains an array
arr = null; //arr is now null or empty
NULLUNDEFINED
Not automatically assigned by JavaScriptAutomatically assigned by JavaScript to variables that are neither declared nor assigned a value.
Data type is objectData type is undefined.
null is a reserved keyword.undefined is not a reserved keyword.
Null Object Every variable that is assigned null has an object. Nevertheless, it is an empty object which have no properties or methods that can be used in manipulating null values. Nulls' typeof() Using the typeof operator on a variable assigned the value, null will return object but then, it is an empty object. According to JS history, null is an object by mistake but then, you may wonder why it hasn't been corrected? Well, it is because it will disrupt a lot of JavaScript programs on the web. SUMMARY
  1. Null is a value assigned to a variable to depict absence of a value.
  2. The typeof operator will return null when used on null.
Take a short quiz on JavaScript Nulls.
Ask a question or tell us if JavaScript Nulls is easy or not.
cent?

Join our 1,090 subscribers to receive tutorials' updates!

  We won't spam your mail box. We hate it.





StackBeginner 2021 © Joseph Omamode