DEV Community

Cover image for Objects in JavaScript.!
Hodiev
Hodiev

Posted on • Edited on

Objects in JavaScript.!

JavaScript Obyektlari.!

Obyektlar judaham ko'p qiymatlarni o'z ichiga olishi mumkin bo'lgan container ,o'zgaruvchi hisoblanadi.!
Obyektlarni obyekt litiralidan foydalanib va obyekt konstruktoridan foydalanib e'lon qilinadi.!
Obyektlarni litiralusulda xosil qilish qulay va foydalanishga tavsiya etiladi.!

object literal

const car={
    type:"BMW",
    price:"50000$",
    wight:"1500kg",
    speed:"300km/h"
};
console.log(car);
// natija - {type: 'BMW', price: '50000$', wight: '1500kg', speed: '300km/h'}
Enter fullscreen mode Exit fullscreen mode

object construktor

const person=new Object();

person.fName="Alexander";
person.lName="Noah";
person.face='have round face';
person.weight='120kg';
person.height='180sm';
person.job='BodyBuilder';

console.log(person);
// natija - {fName: 'Alexander', lName: 'Noah', face: 'have round face', weight: '120kg', height: '180sm', job: 'BodyBuilder'}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)