From f2f6e344106a498aa6cca9060d92d7c719364adb Mon Sep 17 00:00:00 2001 From: kraftwerk28 Date: Sat, 10 Feb 2018 23:42:32 +0200 Subject: [PATCH] added three paradigms --- .eslintrc.yml | 173 +++++++++++++++++++++++++++++++++++++++ JavaScript/class.js | 22 +++++ JavaScript/functional.js | 23 ++++++ JavaScript/prototypal.js | 23 ++++++ LICENSE | 42 +++++----- README.md | 4 +- 6 files changed, 264 insertions(+), 23 deletions(-) create mode 100644 .eslintrc.yml create mode 100644 JavaScript/class.js create mode 100644 JavaScript/functional.js create mode 100644 JavaScript/prototypal.js diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 0000000..a17542c --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,173 @@ +env: + es6: true + node: true +extends: 'eslint:recommended' +globals: + api: false +rules: + indent: + - error + - 2 + - SwitchCase: 1 + VariableDeclarator: + var: 2 + let: 2 + const: 3 + MemberExpression: 1 + linebreak-style: + - error + - unix + quotes: + - error + - single + semi: + - error + - always + eqeqeq: + - error + - always + no-loop-func: + - error + strict: + - error + - global + block-spacing: + - error + - always + brace-style: + - error + - 1tbs + - allowSingleLine: true + camelcase: + - error + comma-style: + - error + - last + comma-spacing: + - error + - before: false + after: true + eol-last: + - error + func-call-spacing: + - error + - never + key-spacing: + - error + - beforeColon: false + afterColon: true + mode: minimum + keyword-spacing: + - error + - before: true + after: true + overrides: + function: + after: false + max-len: + - error + - code: 80 + ignoreUrls: true + max-nested-callbacks: + - error + - max: 7 + new-cap: + - error + - newIsCap: true + capIsNew: true + properties: true + new-parens: + - error + no-lonely-if: + - error + no-trailing-spaces: + - error + no-unneeded-ternary: + - error + no-whitespace-before-property: + - error + object-curly-spacing: + - error + - always + operator-assignment: + - error + - always + operator-linebreak: + - error + - after + semi-spacing: + - error + - before: false + after: true + space-before-blocks: + - error + - always + space-before-function-paren: + - error + - never + space-in-parens: + - error + - never + space-infix-ops: + - error + space-unary-ops: + - error + - words: true + nonwords: false + overrides: + typeof: false + no-unreachable: + - error + no-global-assign: + - error + no-self-compare: + - error + no-unmodified-loop-condition: + - error + no-constant-condition: + - error + - checkLoops: false + no-console: + - off + no-useless-concat: + - error + no-useless-escape: + - error + no-shadow-restricted-names: + - error + no-use-before-define: + - error + - functions: false + arrow-body-style: + - error + - as-needed + arrow-spacing: + - error + no-confusing-arrow: + - error + - allowParens: true + no-useless-computed-key: + - error + no-useless-rename: + - error + no-var: + - error + object-shorthand: + - error + - always + prefer-arrow-callback: + - error + prefer-const: + - error + prefer-numeric-literals: + - error + prefer-rest-params: + - error + prefer-spread: + - error + rest-spread-spacing: + - error + - never + template-curly-spacing: + - error + - never \ No newline at end of file diff --git a/JavaScript/class.js b/JavaScript/class.js new file mode 100644 index 0000000..4074178 --- /dev/null +++ b/JavaScript/class.js @@ -0,0 +1,22 @@ +'use strict'; + +class Fruit { + constructor(type) { + this.type = type; + } + eat() { + console.log(`You ate ${this.type}`); + } +} + +class Apple extends Fruit { + constructor(color) { + super('apple'); + this.color = color; + } +} + +const apple = new Apple('green'); + +console.dir(apple); +apple.eat(); // You ate apple diff --git a/JavaScript/functional.js b/JavaScript/functional.js new file mode 100644 index 0000000..184eda9 --- /dev/null +++ b/JavaScript/functional.js @@ -0,0 +1,23 @@ +'use strict'; + +function Fruit(type) { + this.type = type; + this.eat = () => { + console.log(`You ate ${this.type}`); + }; +} + +function Apple(color) { + Fruit.call(this, 'apple'); + this.color = color; +} + +const apple = new Apple(); + +let value; +for (const name in apple) { + value = apple[name]; + console.log(`${name} : ${value}`); +} + +apple.eat(); // You ate apple diff --git a/JavaScript/prototypal.js b/JavaScript/prototypal.js new file mode 100644 index 0000000..d9f91ff --- /dev/null +++ b/JavaScript/prototypal.js @@ -0,0 +1,23 @@ +'use strict'; + +function Fruit(type) { + this.type = type; + this.eat = () => { + console.log(`You ate ${this.type}`); + }; +} + +function Apple(color) { + this.color = color; +} +Apple.prototype = new Fruit('apple'); + +const apple = new Apple('green'); + +let value; +for (const name in apple) { + value = apple[name]; + console.log(`${name} : ${value}`); +} + +apple.eat(); // You ate apple diff --git a/LICENSE b/LICENSE index 8864d4a..911ea4a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ -MIT License - -Copyright (c) 2017 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +MIT License + +Copyright (c) 2017 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 5b571c0..74075f0 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# Inheritance -Inheritance in Different Paradigms +# Inheritance +Inheritance in Different Paradigms pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy