12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- //3 person
- var a = new Object();
- a.name="";
- a.surname="";
- var b = new Object();
- b.name="";
- b.surname="";
- var c = new Object();
- c.name="";
- c.surname="";
- //different fileds
- a.patronymic="";
- a.collorHair='';
- a.sex='';
- b.collorSkin='';
- b.gender='';
- b.presenceOfChildren='';
- c.collorEyes='';
- c.nationality='';
- c.footSize='';
- //fileds check
- for ( let boobSyzze in a ) {
- if( boobSyzze != "name" || boobSyzze != "surname" || boobSyzze != "patronymic" || boobSyzze != "collorHair" || boobSyzze != "sex" );
- alert(boobSyzze);
- }
- for ( let boobSyzze in b ) {
- if( boobSyzze != "name" || boobSyzze != "surname" || boobSyzze != "collorSkin" || boobSyzze != "gender" || boobSyzze != "presenceOfChildren" );
- alert(boobSyzze);
- }
- for ( let boobSyzze in c ) {
- if( boobSyzze != "name" || boobSyzze != "surname" || boobSyzze != "collorEyes" || boobSyzze != "nationality" || boobSyzze != "footSize" );
- alert(boobSyzze);
- }
- //array of persons
- let persons =[{}, {}, {}];
- for (let key of persons){
- key.name = 'Mary';
- key.surname = 'Jain';
- key.familyDoctor = 'dr.Dre';
- }
- //loop of persons
- for (let key of persons) { console.log(key);}
- //loop of name and surname;
- for (let key in persons){
- console.log(persons[key].name);
- console.log(persons[key].surname);
- }
- // loop of loop of values;
- persons.forEach(function(keyOfPersone){
- for (let key in keyOfPersone){
- console.log(keyOfPersone[key]);
- }
- });
- //full name
- persons.forEach(function(fullN){
- let counter = 0;
- for (let key in fullN){
- if (key==='name')
- counter++;
- }
- if (counter >= 1) {
- fullN.fullname = "Mary Jain";
- }
- })
- //serialize
- let serialize = JSON.stringify(persons);
- console.log(serialize);
- //deserialize
- let deserialize = JSON.parse('{"name": "2pac", "surname": "shakur", "familyDoctor":"Orlando Anderson", "fullName":"Lesane Parish Crooks"}');
- persons.push(deserialize);
- //HTML
- var str = '<table border="1">';
- for (let i = 0; i < persons.length; i++){
- str += '<tr style="background-color:black; color:yellow;">';
- for (let key in persons[i]){
- str += `<td>${persons[i][key]}</td>`;
- }
- str += '</tr>';
- }
- str += '</table>';
- document.write(str);
- //th
|