KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
The Confusing discussion In this question , there is a discussion on the concepts of associated array and object in javaScript which I got a bit confused. In this example code: var check = { pattern : { name: /^[a-zA-Z-\s]{1,20}$/, email: /^[a-zA-Z0-9._(-)]+@[a-zA-Z0-9.(-)]+\.[a-zA-Z]{1,4}$/, pass: /.{6,40}/, url: /^[(-)\w&:\/\.=\?,#+]{1,}$/, aml: /<(.+)_([a-z]){1}>$/ } }; Here is the discussion makes me confused: @steven.yang the outer object is not an associative array in your sample, but that is what is being asked for @sissonb what do you mean by 'outer object is not an associative array'? I think associated array is expressed as object in javascript. The difference is in the notation - either through foo.bar or foo[bar] @steven.yang associated array means key => value. http://en.wikipedia.org/wiki/Associative_array Your inner object has a key of pattern, the object containing this associative array has no key. My Understanding of Associated Array and Objects in JS Associated array is defined as key-value pairs which is expressed as the object in JavaScript. The outer object assigned to check has a key pattern and an value of another object. The inner object has keys of name , email ... and corresponding values of regular expression objects. Could both objects be counted as associative arrays?
Tags (comma-separated)
Save Edits
Cancel