0

I wonder about how JS language itself is implemented (under the hood) I'm mostly interested in how arguments are passed to functions. How does a function 'know' whether an argument is a primitive or an object? for example:

function foo(x) { console.log(x); }
foo(obj.valueOf()) // the type of the argument to foo is not known at compile time...

if JS is written in C, for example, then foo will get void*? or a union {double, char*, void*}

DuduArbel
  • 1,100
  • 1
  • 12
  • 25

0 Answers0