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 :: remove equal objects in list of json js 
Javascript :: react native app exit 
Javascript :: operadores de asignacion javascript 
Javascript :: loop,array javascript 
Javascript :: javascript type 
Javascript :: ternary operator multiple conditions 
Javascript :: javascript variable hoisting 
Javascript :: javascript + Operator with Numbers 
Javascript :: javascript Arguments Binding 
Javascript :: javascript Skip Items 
Javascript :: JavaScript Data Privacy 
Javascript :: javascript statements 
Javascript :: mui on node 
Javascript :: card types regex 
Javascript :: Multiply string using a for loop 
Javascript :: Could not resolve "i18n-iso-countries" 
Javascript :: Warning: Problem validating app.json: Unable to perform cache refresh for 
Javascript :: phaser place items on circle reverse 
Javascript :: phaser generate frame names 
Javascript :: complex expression in programming 
Javascript :: scan token deploy js 
Javascript :: declare 2 d vector js 
Javascript :: sadd in redis 
Javascript :: Slice and Splice -Javascript 2 
Javascript :: convert json to csv npm 
Javascript :: discord js bot leave voice channel 
Javascript :: nextjs app 
Javascript :: Javascript count instances of character in a string 
Javascript :: async storage set 
Javascript :: react native push notifications npm 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =