I'm leaning JavaScript and I've read about the constructor property.
I tried
[].constructorfalse.constructor'abc'.constructor
And they all worked. However to my surprise when trying:
123.constructor{}.constructor
They did not, why is that?
This is a parse issue.
123.constructor the engine experts a decimal after the 123 like 123.123{}.constructor the engine reads {} as an empty block and then reads . as the first thing in the outer block which is meaningless.Both of which can be fixed by wrapping these with ()s
(123).constructor; // Number, note this 'boxes'
({}).constructor; // Object
123..constructor, the first '.' is a decimal mark.{}.constructorworks for me.console.dir({}.constructor);, and that works.