Build JavaScript Objects
var myDog = {
name: "gozi",
legs: 4,
tails: 1,
friends: ["Ted", "Fred"]
};
Build JavaScript Objects
var myDog = {
name: "gozi",
legs: 4,
tails: 1,
friends: ["Ted", "Fred"]
};
objects in javascript
let car = {
engineNumber: 1234
brand: 'BMW',
break: function (){}
}
objects javascript
function Dog() {
this.name = "Bailey";
this.colour = "Golden";
this.breed = "Golden Retriever";
this.age = 8;
}
js create object with properties
function Car(make, model, year) {
this.make = make;
this.model = model;
this.year = year;
}
FUNCION EN OBJETO JAVASCRIPT
//Manera 1
function nombreDelTipoDeObjeto (par1, par2, …, parN) {
this.nombrePropiedad1 = valorPropiedad1;
this.nombrePropiedad2 = valorPropiedad2;
this.método1 = function () { … código …. }
this.método2 = function (param1, param2, …, paramN) { … código …}
}
// Manera alternativa
function nombreDelTipoDeObjeto (par1, par2, …, parN) {
this.nombrePropiedad1 = valorPropiedad1;
this.nombrePropiedad2 = valorPropiedad2;
this.método1 = nombreFuncion1;
this.método2 = nombreFuncion2;
}
function nombreFuncion1 (par1, par2, …, parN) { … código … }
function nombreFuncion2 (par1, par2, …, parN) { … código … }
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us