You really cannot do this because it is a syntax error
function a = function() {};
I guess you just want to say:
function a() {}
Anyway. The reason you cannot get a property from a number is because it is not a real object.
a = 20; a.foo = 30; // this works alert(a.foo); // this alerts nothing
Believe it or not, the same goes for the lines:
a = "ohai"; a.foo = 30; // this works alert(a.foo); // this alerts nothing
However, if it is a String object, it works as expected:
a = new String("ohai"); a.foo = 30;
Or, if it is a Number object. You understand.
String and number literals are not objects in Javascript. This is the reason.
gugod source share