Today we learned more about objects which went into symbols, this, and primitive conversion. Objects are really complex with all of the things they can do.

Objects by default can only either a string or a symbol type. Symbol has some advantages over string, it represents a unique identifier. It is created using symbol(). You can also give symbol a description for debugging purposes. Symbols with the same id are not equal they are guaranteed to be different.

“This” is a method, and methods are functions that are stored in object properties. Method allow objects to “act” like object.doSomething(). Methods can reference the object as “this”. The value of this is defined at run-time. “This” has no value until the function is called. When a function is called in the “method” syntax (object.method()), the value of this during the call is object.

The last topic of today was primitive conversion which was a little weird for me. It allows you to convert an object to a number, string, or default. Converting to string is for when operation expects a string like alert. When an operation expects a number you convert it to number. Default is used with number conversion, just in case an operator doesn’t know what to expect.

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: