“Métodos de objeto JavaScript” Código de respuesta

JavaScript Verificar métodos de objetos

Object.getOwnPropertyNames() 
Clumsy Cobra

Métodos de objeto JS

create()
keys()
values()
entries()
assign()
freeze()
seal()
getPrototypeOf()
Anton Grigoriev

Definir métodos de objetos en JavaScript

objectName.methodname = functionName;

var myObj = {
  myMethod: function(params) {
    // ...do something
  }

  // OR THIS WORKS TOO

  myOtherMethod(params) {
    // ...do something else
  }
};
kirbster102

Método de objeto en JavaScript

const student = {
    id: 101,
    major: "Mathamatics",
    money: 5000,
    name: "Abrar",
    subjects: ["English", "Economics", "Math 101", "Calculus"],
    bestFriend: {
        name: "Kundu",
        major: "Mathematics"
    },
    takeExam: function () {
        console.log(this.name, "taking exam");
    },
    treatDey: function (expense, tip) {
        this.money = this.money - expense - tip;
        return this.money
    }
}
student.takeExam();
//Output: Abrar taking exam
const remaining1 = student.treatDey(900, 100);
const remaining2 = student.treatDey(500, 50);
console.log(remaining1);
console.log(remaining2);
//Output: 4000,3450
Ariful Islam Adil(Code Lover)

Métodos de objeto JavaScript

const person = {
    name: 'Sam',
    age: 30,
    // using function as a value
    greet: function() { console.log('hello') }
}

person.greet(); // hello
SAMER SAEID

Métodos de objeto JavaScript

const person = {
  firstName: "John",
  lastName: "Doe",
  id: 5566,
  fullName: function() {
    return this.firstName + " " + this.lastName;
  }
};
naly moslih

Respuestas similares a “Métodos de objeto JavaScript”

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código