Object Örnekleri

Object Örnekleri
Örnek1
function FormElemanlari(Obj) {

        this.H1 = `<h1>${Obj.H1}</h1>`;
        this.IMG = `<img src="${Obj.Src}" style="${Obj.ImgStil}" />`;
        this.HR = `<hr/>`;
        this.SEHIR = Obj.Sehir;
        this.MESLEK = Obj.Meslek || "Bilinmiyor"; // Eğer meslek gelmezse "Bilinmiyor"
        this.ULKE = "Türkiye";

        this.TAMISIM = function () {
            B = " ";
            return this.ADI + B +
                    this.SOYADI + B +
                    this.YAS + B +
                    this.MESLEK + B +
                    this.SEHIR + B +
                    this.ULKE;
        }
    };

    const Veriler = {
        H1: 'Beylikdüzü',
        Src: 'https://www.odkadekor.com.tr/idea/jr/24/myassets/blogs/blog-102.jpeg?revision=1746482954',
        ImgStil: 'width:100px; height:auto;',
        P: 'Gümüş',
        BIna: 'Mavi Kent',
        DAire: 13,
        SAhibi: 'Mehmet'
    };
    HTML = new FormElemanlari(Veriler);

    FormElemanlari.prototype.P = `<p>${Veriler.P}</p>`; //yoktu eklendi

    for (i = 0; i < 100; i++) {
        document.write(HTML.H1 + HTML.HR + HTML.IMG + HTML.P);
    }

 

 

Yükleniyor...
Yükleniyor...