Js adding Modify and Deleting Properties

Object Basics with Dot Bracket Notation

    const profile={
    name:'Bhushan',
     age:20,
     sex:'Male',
 }
 console.log(profile);
 console.log(profile.name);
 console.log(profile['name']);    
 

Adding, Modifying Deleting Properties

Adding Properties

  const profile={
    name:'Bhushan',
     age:20,
    sex:'Male',
 }
//profile.email='admin@admin.com'
profile['email']='admin@admin.com'
  console.log(profile);

Update Properties

  const profile={
    name:'Bhushan',
     age:20,
     sex:'Male',
     married:true
 }
profile.married=false;
profile.name='Ramesh Kumar';
profile.age=age+3;

console.log(profile);

Delete Properties

   const profile={
    name:'Bhushan',
     age:20,
     sex:'Male',
     married:true
 }

delete profile.name

console.log(profile);

Comments

Popular posts from this blog

JS Rest Parameter

How to Add Social Media Share Buttons in Laravel?