Javascript examples for Language Basics:Introduction
You can define an object and its properties in one step using the object literal format.
<!DOCTYPE HTML> <html> <head> <title>Example</title> </head> <body> <script type="text/javascript"> var myData = {//from w ww . ja v a 2 s.c om name: "java2s.com", topic: "CSS" }; document.writeln("Hello " + myData.name + ". "); document.writeln("Today is " + myData.topic + "."); </script> </body> </html>