Please explain everything to me about 'Objects'


#1

Please explain everything to me about 'Objects'.


#2

Let's start with this sentence. When I click Reply it will get sent to this page as a post and the program will parse it and strip any illegal characters or text then hand it to the database to be stored with a unique id, which will then be sent back to this page as a post number and appear below yours.

This post is an object. The container, is an HTML <div></div> element, also an object whose attributes contain layout information through class names, the principal one being, topic-post.

The attribute is an object.The CSS selector rules are, you guessed it, also objects.

"This string" is an object that belongs to a predefined class (a built-in), namely, String. But it doesn't start out as an object. The text inside the quotes is called a primitive. Primitves are not objects. JavaScript provides them with a wrapper object most closely associated with it, which in this case is a string object wrapper. Now it's an object.

Quoted strings are primitives, as we've said, and so are numbers, booleans and null. All of these need wrapper objects.

A line of code is an object, and strictly speaking it could even be construed as data if we abstract it enough as some newer languages do. We won't consider code as anything but code, for the time being. It's objectness is at a lower level in the architecture. We are focused on the higher level language constructs, namely, data objects.

So it would seem that apart from primitives, everything is an object, and if you thought this, then you would be correct. Wrap your head around that for a minute or two and we can continue this conversation.

Up to now I have tried to not be technical or didactic. If someone pipes in with a canned answer, please don't let it dissuade you from continuing this discourse.

Let's now consider data structures. Just the name implies objects. That's the road we will go down next.