the assignment puzzle

the case

  • what all can be assigned to a variable
  • it is a totally stupid question
  • if arrays and objects can, why not loops (iterations) – or are iterations and conditions treated separately (i.e. they are not data structures)


  • variable is a value-holder (h-o-l-d-e-r !!!)
  • variable it is not an alias/shorthand for lengthier code like I attempted to do with loops (use functions for this)
  • these values are of various kind and these elements are called data types and there is 6+1
  • 6 primitives – they have no properties
    • boolean (yes or no)
    • string (name)
    • number (age)
    • undefined (nothing)
    • null (nonsense)
    • symbol (?)
  • 1 object
    • this one works differently all the way down to the physical layer, i.e. memory allocation !!!
    • Objects are special – pay attention ! it is manipulated by reference

Primitive-Assignment vs Object-Assignment

  • Not a 100% analogy, but as an Excel-fan I think of an assignment of value with another variable as a paste as value command, not linking the fields of my sheet
  • On the other hand, assigning the existing object to a variable is to create a field with an address to another field, thus making it automatically change with original one
    • The problem here is that (as shown in the red field) the original field in JS is also an address and you store the actual objects elsewhere


Leave a Reply

Your email address will not be published. Required fields are marked *