As converts a value of type Number when you call foo.call(10)?

Hello ! From the theory about the methods call ( ) and apply ( ) read that if the brackets these methods to pass primitive values ( like string, boolean , or number) , then it's primitive value is wrapped in its object form (new String ( . . .) , new Number ( . . . ), etc.)

Most likely I misunderstood this expression , t . to . the code below is not working .

function n ( ) {
 document.write( this.a )
};

Number.a = 100 ;

n.call( 10 ) ; // returns undefined


I assumed that passing in the function n.call( 10 ) a primitive value (10) I can get to properties of a object Number , but unfortunately undefined !
1 ) please Explain why my code is not working !
2 ) If you do not complicate any simplistic example bring still the transfer case of primitive values in the function call ( ) and apply ( ), like they would with the object Number ( ) and Boolean ( ) , and most importantly, where it can be used !
Thank you in advance !
April 4th 20 at 00:38
1 answer
April 4th 20 at 00:40
Solution
Properties and methods are sought not in the static properties constructor and prototype, ie:
Number.a = 100; // no
Number.prototype.a = 100; // Yes
@Maxim Zaitsev, Thanks for the prompt answer , I think you should carefully read about the prototypes ! Just out of my head example :

function as( ) {
 as.a = 10
 as.loo = loo
 as.loo.call( as )
} ;

function loo( ){
 document.write( this.a )
} ;

as( )


Indeed, in this example, we add in a function OBJECT property as.a = 10 and it appears this function OBJECT ! But why in my question when I add to essentially the same function Number( ) property of a result not work ! ? Because Number( ) is also a function , well even designer ! Hmm , it is unclear how they differ , t . to . nirazu heard that functions from constructors is no different ! ? - alvera_Mitchell commented on April 4th 20 at 00:43
@alvera_Mitchell, answer this:
function n ( ) {
 document.write( this.a )
};

Number.a = 100 ;

n.call(Number) ; // returns 100

Continue reading learn.javascript.ru ) - margarete_Breitenbe commented on April 4th 20 at 00:46

Find more questions by tags JavaScript