123456789101112131415161718192021222324252627282930313233 |
- <header>
- <h1>Literals expand</h1>
- </header>
- <body>
- <script>
- const cat =
- {
- "head":
- {
- "name": "cat's head",
- "ears": [{ "name": "ear", "attrs": { "position": "left" } }, { "name": "ear", "attrs": { "position": "right" } }],
- "eyes": [{ "name": "eye", "attrs": { "position": "left" } }, { "name": "eye", "attrs": { "position": "right" } }],
- "mouth": "cat's"
- },
- "body":
- {
- "name": "cat's body",
- "paws":
- [
- { "name": "paw", "attrs": { "position": "left", "placement": "front" } },
- { "name": "paw", "attrs": { "position": "right", "placement": "front" } },
- { "name": "paw", "attrs": { "position": "left", "placement": "rear" } },
- { "name": "paw", "attrs": { "position": "right", "placement": "rear" } },
- ],
- "tail": "cat's tail"
- }
- }
- cat[prompt("Enter property name")] = prompt("Enter property value");
- cat[prompt("Enter property name")] = prompt("Enter property value");
- </script>
- </body>
|