Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for Are Javascript arrays primitives? Strings? Objects?

Current License: CC BY-SA 2.5

24 events
when toggle format what by license comment
Feb 19, 2011 at 4:14 comment added Šime Vidas @Jared Yes, the type Object is the one and only non-primitive type in JavaScript.
Feb 19, 2011 at 4:09 comment added Jared Farrish @Šime Vidas - "one non-primitive type" = Objects?
Feb 19, 2011 at 4:07 comment added Šime Vidas @Jared So your question is: How is it possible that non-primitive types exist? But why wouldn't they exist? In JavaScript, there are 5 primitive types, and one non-primitive type.
Feb 19, 2011 at 4:01 comment added Jared Farrish @Šime Vidas - So how does Javascript explain a type that is not a primitive?
Feb 19, 2011 at 3:59 comment added Šime Vidas @Jared The type is named Object. Objects are values of the type Object.
Feb 19, 2011 at 3:56 comment added Jared Farrish @Šime Vidas - Yes, but what type? There has to be a bridge here. If an object is not a String, Integer, or Boolean, what is it? What do I not know?
Feb 19, 2011 at 3:53 comment added Šime Vidas @Jared String is a primitive type. Object is a different type. Objects are not Strings, the same way as Strings are not Numbers. They are just two different types.
Feb 19, 2011 at 3:43 comment added Jared Farrish @Šime Vidas - And I am saying again, what are objects? Strings? And I terribly conflicted?
Feb 19, 2011 at 3:37 comment added Šime Vidas @Jared Array are objects. Arrays are values of the type Object. (I'm saying this for the third time. :))
Feb 19, 2011 at 3:34 comment added Jared Farrish @Šime Vidas - So what are they?
Feb 19, 2011 at 3:32 comment added Šime Vidas @Jared There are 5 primitive types in Javascript: Number, String, Boolean, Null, Undefined. ... Object is not a primitive type.
Feb 19, 2011 at 3:21 comment added Jared Farrish @aiham - No, that's not what I was asking specifically, merely an attribute of what I wanted explained. If a primitive type object does not exist in JS, are objects Strings? What's the definitive answer? Can you explain? I would note my understanding of arrays were that they were objects in memory, regardless.
Feb 19, 2011 at 3:18 comment added aiham Secondly, I didn't realise that's what you were asking. I just thought you wanted to know how to use Objects in the Javascript language. Not how the browser stores them in memory after parsing your script. I'd say that you should change your question to be exactly that, and add a few more tags related to which browser you want to know about and in what language the browser was written, because I'm sure those would have an effect.
Feb 19, 2011 at 3:16 comment added aiham Firstly, let me rephrase that, 'doesnt need to know about pointers and how memory is stored'. Of course you do have to worry about memory and taking too much of it.
Feb 19, 2011 at 3:12 comment added Jared Farrish "A Javascript developer doesn't need to know about memory to develop in Javascript" - @aiham - I think you should incorporate this into your answer. Is this really not part of the answer, the puzzle?
Feb 19, 2011 at 3:05 comment added aiham Well I'm not sure how objects are stored in memory, but I'd guess it would depend on the browser. A Javascript developer doesn't need to know about memory to develop in Javascript. It's a much lower level issue than Javascript deals with. You don't have access to memory or pointers in it like other lower level languages. (You can set variables for garbage collection with 'delete' though). It's all done for you. If you are that interested in how the browser stores objects in memory, then you'd be better served asking in an open-source browser development community, such as Mozilla's.
Feb 19, 2011 at 2:56 comment added aiham Indeed it is. I've only gotten interested in Javascript prototypes recently, and it's been really intriguing playing around with it all. You can make some pretty powerful applications by taking advantage of objects and prototypes. You should read some things Douglas Crockford has to say about Javascript ( javascript.crockford.com ), a lot of is quite useful (Some is a bit over the top).
Feb 19, 2011 at 2:54 comment added Jared Farrish To your second edit, if there is no primitive type Object, how do Objects relate to Javascript? Wouldn't they then be strings in memory? I don't see a way of relating back the primitive types of String, Boolean and Integer. Does that make sense?
Feb 19, 2011 at 2:47 comment added Jared Farrish "So all arrays you've ever used in Javascript are objects and instances of Array's prototype property." That's a fascinating statement.
Feb 19, 2011 at 2:46 history edited aiham CC BY-SA 2.5
added 304 characters in body
Feb 19, 2011 at 2:29 history edited aiham CC BY-SA 2.5
minor wording change
Feb 19, 2011 at 2:27 comment added aiham I apologise for my incorrect wording. You're right, it references the prototype's contents. So if the prototype is modified after your instance object is created, the instance object will also be affected. I will modify my answer.
Feb 19, 2011 at 2:26 comment added Šime Vidas @aiham ... and when you use the new keyword on an object with a prototype property, it creates a clone of the contents of the prototype and stores them in your variable. This is not true. The contents of the prototype object are not cloned, but the instance object that is created just has a reference to that prototype (and its methods).
Feb 19, 2011 at 2:20 history answered aiham CC BY-SA 2.5
toggle format

AltStyle によって変換されたページ (->オリジナル) /