Click here to Skip to main content
15,896,727 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
whether object type in JavaScript is primitive type?
because object type in .net is a primitive type.
in JavaScript there is a object class,whether object type wrapped to in class(object)?
if yes thus object is a primitive type where are reference(Like c#)

i read where all of primitive type in JavaScript wrapped to a object.
(javaScript definitive guide book)
Posted
Comments
ZurdoDev 2-Feb-12 9:32am    
Is there a question somewhere?
[no name] 2-Feb-12 9:34am    
whether object in js consist of primitive types?
Sergey Alexandrovich Kryukov 2-Feb-12 14:40pm    
Oh man! Where did you get this weird information?
--SA
Rajesh Anuhya 2-Feb-12 21:08pm    
Confused.

1 solution

The question is incorrect in principle because JavaScript is interpretive language using loose typing (dynamic, weak, duck typing discipline).

Please see http://en.wikipedia.org/wiki/JavaScript[^].

There is no a concept of a primitive type in JavaScript. More exactly, the way of interpretation of "bare" integer or Boolean values (they only exist explicitly as the result of Boolean operations) is implementation-dependent. In a way, it does not matter, because there is no such thing as a type of a variable. But "all of primitive type in JavaScript wrapped to a object" is generally not true, at least from the standpoint of JavaScript developer. You can find it out writing something like value = 13 and examining value under Debugger. By the way, all "complex" JavaScript objects are merely the associative arrays: http://www.quirksmode.org/js/associative.html[^].

Don't mix it up with .NET boxing, which is also not something which "always" happen. :-)

Object type in C# is not a primitive type, and C# and JavaScript methods never call each other. If you have such illusion, this is maybe only because C# methods generate some text of some JavaScript code on the server side, parametrize generation of text to insert same values calculated on the server side, but ultimately everything is done just through generation of code text and nothing else. This is how ASP.NET works with JavaScript. There is nothing else. There is no point in comparison these two languages.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900