Advertisement
soden

Untitled

Feb 28th, 2024
573
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.38 KB | Source Code | 0 0
  1. // Definisi kelas menggunakan ES6
  2. class Mahasiswa {
  3.     constructor(nama, nim, jurusan) {
  4.         this.nama = nama;
  5.         this.nim = nim;
  6.         this.jurusan = jurusan;
  7.     }
  8.  
  9.     getInfo() {
  10.         return this.nama + " (" + this.nim + ") - " + this.jurusan;
  11.     }
  12. }
  13.  
  14. let mahasiswa1 = new Mahasiswa("Syarif", "12345", "Informatika");
  15. console.log(mahasiswa1.getInfo());
  16.  
Tags: JavaScript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement