Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

access an object js

 // Access an object's properties
 const person1 = {};
 person1['firstname'] = 'Mario';
 person1['lastname'] = 'Rossi';

 console.log(person1.firstname);
 // expected output: "Mario"

 const person2 = {
    firstname: 'John',
    lastname: 'Doe'
 };

  console.log(person2['lastname']);
  // expected output: "Doe"
 
PREVIOUS NEXT
Tagged: #access #object #js
ADD COMMENT
Topic
Name
6+4 =