creating an object javascript
let obj = {
// fields
name:"value",
num: 123,
//methods
foo: function(){}
}
creating an object javascript
let obj = {
// fields
name:"value",
num: 123,
//methods
foo: function(){}
}
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 … }
literal object js
var car = {type:"Fiat", model:"500", color:"white"};
javascript object literal
const myObject = {
property: 'Value!',
otherProperty: 77,
"obnoxious property": function() {
// do stuff!
}
}
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