Prev Demo
Creating Object By Using Object Literals In Object Oriented Programming
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Creating object by using object literals</h1> <script> var myDresses = {}; var shoe = { color: "blue", type: "sports", size: 8, HowComfortableAmI: function () { console.log("Very Very Comfortable"); } } alert("Shoes (Object) are Very Very Comfortables"); </script> <p><strong>Note:</strong> Here we are creating objects by using object literals method, In thhis case objects are shoes. It has mentioned properties color, type, & size. Comfortness is given separately to the function. <br> So the alert returns the comfortableness of the object.</p> </body> </html>
Note: We DO NOT save your trial code in our database.
Output