JavaScript already allows you to assign anything possible to the same variable (integer, string, array, object, etc.), thanks to the versatility of the var keyword, though the elite coder might aruge that this, not only encourages laziness which, in turn, lowers the IQ, but, per se, is, somewhat, a worst-case-scenario vulnerability, being that it is easier to intercept a variable in memory and exploit whatever its content is without having to figure out what 'type' it is. Consider a company that manufactures locks, and keys for them that have the same pattern: any key can open any lock regardless of the purpose the lock is used for.
What would make the language more interesting though is (epitomizing DHTML in its true sense), the ability to create variables with variable names and: var "foo" + "bar" = null; is not possible.
CONDITION:
i. You want to store and manipulate separate values with similar patterns (which could be done using arrays), but:
ii. All of the values will not always be used (so arrays would waste memory resources, plus a space used by one value could always be freed for another), and definitely not in the same order all the time, and:
iii. You always want to access them as they are stored regardless of which one is stored first, so:
iv. It sounds as if indexing the variables (currently being used), with some sort of naming convention, is a good idea, therefore:
v. The 'Object' object comes to mind; finally:
vi. The underlying concept here, is the ability to (not always) store and/or (not always) manipulate, some/any/all of the content of similar objects in a particular scope, using the same limited, unrecurring code.
|
No comments:
Post a Comment
Leave a comment...