From 62e5b4ec21e1fb0ebe0687728e12cfd8ca301779 Mon Sep 17 00:00:00 2001 From: mohammed ashfaq Date: Thu, 12 Mar 2020 17:21:14 +0530 Subject: [PATCH 1/2] implemeted Class and sub Class --- class.js | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++ subClass.js | 22 ++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 class.js create mode 100644 subClass.js diff --git a/class.js b/class.js new file mode 100644 index 0000000..abaf095 --- /dev/null +++ b/class.js @@ -0,0 +1,67 @@ +// Method1 + +function User(name, city) { + let userObject = Object.create({}); + userObject.name = name; + userObject.city = city; + Object.setPrototypeOf(userObject, User.prototype); + return userObject; +} + +User.prototype.getName = function() { + return this.name; +}; + +user1 = User("ricky", "hyderabad"); + +// Method 2 + +function User(name, city) { + let userObject = Object.create(User.prototype); + userObject.name = name; + userObject.city = city; + return userObject; +} + +User.prototype.getName = function() { + return this.name; +}; + +user1 = User("ricky", "hyderabad"); + +// Method 3 + +function User(name, city) { + this.name = name; + this.city = city; +} + +User.prototype.getName = function() { + return this.name; +}; +var user1 = new User("ricky", "hyderabad"); + + +// Method4 + +class User { + constructor(name, city) { + this.name = name; + this.city = city; + } + render() { + return this; + } + + getName() { + return this.name; + } + + getCity() { + return this.city; + } +} +var data = () => {}; + +var user1 = new User("ricky", "hyderabad"); + diff --git a/subClass.js b/subClass.js new file mode 100644 index 0000000..d010f5a --- /dev/null +++ b/subClass.js @@ -0,0 +1,22 @@ +function User(name, city) { + this.name = name; + this.city = city; +} + +User.prototype.getName = function() { + return this.name; +}; + +function superUser(name, city, balance) { + User.call(this, name, city); + this.balance = balance; +} + +superUser.prototype = Object.create(User.prototype); +// Object.setPrototypeOf(superUser.prototype, User.prototype); + +superUser.prototype.getBalance = function() { + return this.balance; +}; +var superUser1 = new superUser("ricky", "hyderabad", 100); +console.log(superUser1); From 39eb0bef5122eeac3d8144cdaa77710df0a2a1ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Jan 2021 13:22:14 +0000 Subject: [PATCH 2/2] Bump axios from 0.19.0 to 0.21.1 Bumps [axios](https://github.com/axios/axios) from 0.19.0 to 0.21.1. - [Release notes](https://github.com/axios/axios/releases) - [Changelog](https://github.com/axios/axios/blob/v0.21.1/CHANGELOG.md) - [Commits](https://github.com/axios/axios/compare/v0.19.0...v0.21.1) Signed-off-by: dependabot[bot] --- package-lock.json | 36 +++++++----------------------------- package.json | 2 +- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index 63c3f92..fc78d6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,39 +5,17 @@ "requires": true, "dependencies": { "axios": { - "version": "0.19.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz", - "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==", + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", "requires": { - "follow-redirects": "1.5.10", - "is-buffer": "^2.0.2" - } - }, - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "requires": { - "ms": "2.0.0" + "follow-redirects": "^1.10.0" } }, "follow-redirects": { - "version": "1.5.10", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", - "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", - "requires": { - "debug": "=3.1.0" - } - }, - "is-buffer": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", - "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.1.tgz", + "integrity": "sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg==" } } } diff --git a/package.json b/package.json index 5bcb75d..fe312c2 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,6 @@ "author": "mohammedashfaq.nitk@gmail.com", "license": "ISC", "dependencies": { - "axios": "^0.19.0" + "axios": "^0.21.1" } }