“JavaScript -Objektmethoden” Code-Antworten

JavaScript -Objektmethoden prüfen

Object.getOwnPropertyNames() 
Clumsy Cobra

Methoden des Objekts js

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

Definieren Sie Methoden von Objekten in JavaScript

objectName.methodname = functionName;

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

  // OR THIS WORKS TOO

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

Objektmethode in 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)

JavaScript -Objektmethoden

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

person.greet(); // hello
SAMER SAEID

JavaScript -Objektmethoden

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

Ähnliche Antworten wie “JavaScript -Objektmethoden”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen