জাভাস্ক্রিপ্টে সত্যিকারের ব্যক্তিগত পদ্ধতি তৈরি করার ফলে প্রতিটি বস্তুর ফাংশনের নিজস্ব কপি থাকে। বস্তুটি নিজেই ধ্বংস না হওয়া পর্যন্ত এই কপিগুলি আবর্জনা সংগ্রহ করা হয় না৷
উদাহরণ
var Student = function (name, marks) {
this.name = name || ""; //Public attribute default value is null
this.marks = marks || 300; //Public attribute default value is null
// Private method
var increaseMarks = function () {
this.marks = this.marks + 10;
};
// Public method(added to this)
this.dispalyIncreasedMarks = function() {
increaseMarks();
console.log(this.marks);
};
};
// Create Student class object. creates a copy of privateMethod
var student1 = new Student("Ayush", 294);
// Create Student class object. creates a copy of privateMethod
var student2 = new Student("Anak", 411); এর একটি অনুলিপি তৈরি করে