Modify Object Literal Properties In JavaScript

Modify Object Literal Properties In JavaScript

Modify Object Literal Properties In JavaScript

 

This Article is a continue of the previous Blog here

In this Article i will show you how to create a function to change the Object Literal Properties In JavaScript

In this Javascript Sample Code i will Create 2 function

  1. modiObj(modiName) -> This  will loop through the array to find the Object that the User want to Change, then it will call the  change(obj,ser) , where it will change the existing Serial Number with the new inputted Serial Number.
  2. change(obj,ser) -> Change the Object Literal Properties ” Serial Number ” from the existing Serial Number to new Serial Number.

How to Use

  1. Enter  the Clone Properties and Create a few Clone Object
  2. Key in the Clone Name where you want to modify the Serial Number
  3. Key  in the New Serial Number and Click  ” Modify “

Start Cloning

Clone Name :

Serial Number :

Gender :

Terminate :

Modify Serial Number

Name To Modify

New Serial

CODE Snipplet


function change(obj,ser) {


obj.serialNumber = ser;

}

function modiObj(modiName){



removearray = document.getElementById("modiName").value;

var arraylength = allBots.length;

// search for the Bot Name
for(var i=0; i<arraylength;i++) {

if (removearray == allBots[i].name){

// If you get the Bot Name , replace the Serial Number

// Get the Object Name

funName = clbot[i];

val1 = document.getElementById("newSerial").value;

change(clbot[i],val1);



break;
}


}



}

Leave a Reply

Your email address will not be published. Required fields are marked *

4 + ten =