Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Javascript allocate 32 bits of memory for variables with an undefined value?

Tags:

javascript

Suppose I have the following function signature:

function test(varible1, varible2) {}

When I call it I pass only one parameter:

test(5);

So within test function the variable2 still be created but will have value of undefined. I'm wondering if js engine still allocates 32 bit in the memory for that variable?

like image 389
Max Koretskyi Avatar asked Nov 09 '22 18:11

Max Koretskyi


1 Answers

I can't find the size of undefined and I'm sure it varies with engine, but I assume that the best case is 32 bits. The variable exists, so it needs a value to even know it's undefined. That value is very likely a pointer which will be 32 or 64 bits.

like image 167
Luggage Avatar answered Nov 14 '22 22:11

Luggage