From 394a38aaf149c7137e077a95c8102c1d8c682ff8 Mon Sep 17 00:00:00 2001 From: Aman <140422752+githubAmanKumar@users.noreply.github.com> Date: Tue, 19 Mar 2024 11:12:43 +0530 Subject: [PATCH] Add files via upload --- 10_Classes_and_OOP/oop.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 10_Classes_and_OOP/oop.js diff --git a/10_Classes_and_OOP/oop.js b/10_Classes_and_OOP/oop.js new file mode 100644 index 0000000..22ee7f5 --- /dev/null +++ b/10_Classes_and_OOP/oop.js @@ -0,0 +1,31 @@ +const user = { + username: "Aman", + loginCount: 8, + signedIn: true, + getUserDetails: function () { + // console.log("Got user details from database"); + // console.log(`Username : ${this.username}`); + console.log(this); + } + +} + +// console.log(user.username); +// console.log(user.getUserDetails()); +// console.log(this); + +function User(username,loginCount,isLoggedIn) { + this.username= username; + this.loginCount= loginCount; + this.isLoggedIn= isLoggedIn; + this.greet= function(){ + console.log(`Welcome ${username}`); + }; + + return this //implicitly defined +} +const userOne = new User("Aman",2,true); +const userTwo = new User("Hitesh",2,false); + +// console.log(userOne.constructor); +console.log(userOne.instanceof); \ No newline at end of file