Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript null or object

 What it is  	 		What output shows you 
 				when you write |console.log(typeof(variable);
Undefined:					"undefined"
Null:						"object"
Boolean:					"boolean"
Number:						"number"
String:						"string"
Function object:			"function"
E4X XML object:				"xml"
E4X XMLList object:			"xml"
NodeList					"Nodelist [more data]"
HTMLCollection				"HTMLCollection(1) [more data]"
Comment

null is object in javascript

yes it is!
Comment

why null is an object in javascript

Crazy JavaScript :D 
Comment

why null is object in javascript

As promised, now let’s look as to why the type of null is an “object”. As it 
then indicates that null must be an object, which is not true. In fact,
  null is one of the primitive values in JavaScript.

It is actually a bug in the language and unfortunately can’t be fixed that 
easily, as it will break the existing codebase.

However, there is actually one logical explanation behind why null is an object
in javascript.

In the initial version of JavaScript, values were stored in 32 bit units. 
The first 3 bits represented the data type tag followed by the remaining bits 
that represented the value.

For all objects it was 000 as the type tag bits. null was considered to be a 
special value in JavaScript from its very first version. null was 
a representation of the null pointer. However, there were no pointers in
  JavaScript like C. So null simply meant nothing or void and was represented
  by all 0’s. Hence all its 32 bits were 0’s. So whenever the JavaScrit 
  interpreter reads null, it considers the first 3 bits as type “object”. 
  That is why typeof null returns “object”.
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to scroll automatically to the bottom of the page using javascript 
Javascript :: change string to int javascript 
Javascript :: react native new project 
Javascript :: .reverse javascript string 
Javascript :: mongoose schema for nested items 
Javascript :: password validation in javascript 
Javascript :: javascript add item to array 
Javascript :: js duplicate 
Javascript :: static in class javascript 
Javascript :: if anagram 
Javascript :: ajax get request javascript 
Javascript :: id multiple same property array combining 
Javascript :: javascript prefill form 
Javascript :: heroku 
Javascript :: vue__WEBPACK_IMPORTED_MODULE_0__.reactive) 
Javascript :: ring add an attribute to the object 
Javascript :: javascript Display Undeclared Variable 
Javascript :: javascript for...of with Maps 
Javascript :: how to locate an object with a spcific key in js array 
Javascript :: Källmappningsfel: Error: NetworkError when attempting to fetch resource. Resurs-URL: moz-extension://f820ec62-0644-495b-9cd6-fe7d01cdd955/browser-polyfill.js Källmappnings-URL: browser-polyfill.min.js.map 
Javascript :: pyautogui javascript 
Javascript :: How to Update the Props of a Rendered Component in vue Testing Library 
Javascript :: adding transition to collapse button js 
Javascript :: phaser create animation from canvas texture 
Javascript :: chakra ui with humburger menu 
Javascript :: chai promise resolved 
Javascript :: TypeError: (0 , import_dev.useParams) is not a function remix 
Javascript :: offline bot command discord.js 
Javascript :: react native countdown 
Javascript :: react time picker 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =