⊗jsOpBsOC 24 of 60 menu

JavaScript OOP හි වස්තු සංසන්දනය කිරීම

වස්තු අඩංගු විචල්ය සංසන්දනය කරන ආකාරය බලමු. විචල්ය දෙකක් සමාන ලෙස සැලකේ, ඒවා එකම වස්තුවකට යොමුවක් අඩංගු නම්. ප්‍රායෝගිකව බලමු. අපට පහත පන්තිය ඇති යැයි සිතමු:

class User { constructor(name) { this.name = name; } }

මෙම පන්තියේ වස්තු දෙකක් සාදමු:

let user1 = new User('1'); let user2 = new User('2');

එකම වස්තුවකට යොමුවක් අඩංගු විචල්ය සංසන්දනය කරමු:

console.log(user1 === user1); // true

දැන් වෙනස් වස්තුවලට යොමුවක් අඩංගු විචල්ය සංසන්දනය කරමු:

console.log(user1 === user2); // false

පහත කේතයේ සංසන්දනයේ ප්‍රතිඵලය කුමක්දැයි පැහැදිලි කරන්න:

class Employee { constructor(name) { this.name = name; } } let emp1 = new Employee('john'); let emp2 = new Employee('eric'); console.log(emp1 === emp2);

පහත කේතයේ සංසන්දනයේ ප්‍රතිඵලය කුමක්දැයි පැහැදිලි කරන්න:

class Employee { constructor(name) { this.name = name; } } let emp1 = new Employee('john'); let emp2 = new Employee('eric'); console.log(emp1 === emp1);

පහත කේතයේ සංසන්දනයේ ප්‍රතිඵලය කුමක්දැයි පැහැදිලි කරන්න:

class Employee { constructor(name) { this.name = name; } } let emp1 = new Employee('john'); let emp2 = new Employee('john'); console.log(emp1 === emp2);

පහත කේතයේ සංසන්දනයේ ප්‍රතිඵලය කුමක්දැයි පැහැදිලි කරන්න:

class Employee { constructor(name) { this.name = name; } } let emp1 = new Employee('john'); let emp2 = new Employee('eric'); console.log(emp1 !== emp1);

පහත කේතයේ සංසන්දනයේ ප්‍රතිඵලය කුමක්දැයි පැහැදිලි කරන්න:

class Employee { constructor(name) { this.name = name; } } let emp1 = new Employee('john'); let emp2 = emp1; console.log(emp1 === emp2);

පහත කේතයේ සංසන්දනයේ ප්‍රතිඵලය කුමක්දැයි පැහැදිලි කරන්න:

class Employee { constructor(name) { this.name = name; } } let emp1 = new Employee('john'); let emp2 = new Employee('eric'); console.log(emp1 !== emp2);

පහත කේතයේ සංසන්දනයේ ප්‍රතිඵලය කුමක්දැයි පැහැදිලි කරන්න:

class Employee { constructor(name) { this.name = name; } } let emp1 = new Employee('john'); let emp2 = emp1; emp2.name = 'eric'; console.log(emp1 === emp2);
සිංහල
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEnglishEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
අපි වෙබ් අඩවිය ක්‍රියාත්මක කිරීම, විශ්ලේෂණය සහ පුද්ගලීකරණය සඳහා කුකී භාවිතා කරමු. දත්ත සැකසීම සිදුකරනු ලබන්නේ ගෝපනීයතා ප්‍රතිපත්තිය අනුව ය.
සියල්ල පිළිගන්න කොන්දේසි ප්‍රතික්ෂේප කරන්න