>I really didn't expect any output. It was doing fine until I used new. Without 
>new it returns a >number object. But when I tried to use new and logged it on 
>the console, there I saw this >output. Couldn't understand whether its a 
>number or its an object.

*Plug for JavaScript Patterns by Stoyan Stefanov.*
Chapter 3 has a great description of primitive wrapper objects vs built-in 
constructors (Number).  Gist is that primitives such as 42 aren't objects.  
Objects can have methods and properties but primitives cannot.  Behind the 
scenes when you say 42.toString() it's creating an object that has a toString 
method that can then be called.  So when you call the constructor with new, it 
gives you the object as opposed to the primitive.

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to