Objects and garbage collection was today’s topic. Also some more experimenting happened today. The new experiment was making flash cards to memorize definitions and syntaxes.
A property is a “key: value” pair, where
key is a string (also called a “property name”), and
value can be anything.
I liked the example being referred to as a key being into crypto keys are a keyword. Anything can be an object, but if it’s multiple words it has to be in quotes.
Objects are assigned and copied by reference. In other words, a variable stores not the “object value”, but a “reference” (address in memory) for the value. So copying such a variable or passing it as a function argument copies that reference, not the object. All operations via copied references (like adding/removing properties) are performed on the same single object.
Garbage collection is performed automatically. When objects are not reachable they are deleted. As mentioned before when objects are saved in reference they are saved in memory. However, reference is not equivalent to reachability. As long as the root is not reachable all of the other references are invalid and unreachable. The root is the first thing referenced.
<div class='sharedaddy sd-block sd-like jetpack-likes-widget-wrapper jetpack-likes-widget-unloaded' id='like-post-wrapper-155635758-208-5d0777c057f2c' data-src='https://widgets.wp.com/likes/#blog_id=155635758&post_id=208&origin=trilamanila.com&obj_id=155635758-208-5d0777c057f2c' data-name='like-post-frame-155635758-208-5d0777c057f2c'><h3 class="sd-title">Like this:</h3><div class='likes-widget-placeholder post-likes-widget-placeholder' style='height: 55px;'><span class='button'><span>Like</span></span> <span class="loading">Loading...</span></div><span class='sd-text-color'></span><a class='sd-link-color'></a></div>