Objects-1

 

Object is a list of data types that is stored as a series of name-value pairs. Each key is known as property in javascript. In this example, We are declaring person as an object with four properties firstName,lastName,age and eyeColor with value as "Michael", "Voughan", 40 and blue, Here is how we can concatenate firstName and lastname from object: person.firstName + " " + person.lastName See the code snippet:

 
 
 
<!DOCTYPE html> <html> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <p>Creating Object.</p> <p id="sample"></p> <script> var person = { firstName : "Michael", lastName : "Voughan", age : 40, eyeColor : "blue" }; document.getElementById("sample").innerHTML = person.firstName + " " + person.lastName; </script> </body> </html>
Output