├── docs ├── _config.yml ├── Setting-up-you-mac-machine.md ├── Learning-Resources-That-Rocks!.md ├── Tools-&-Frameworks.md ├── JavaScript:-Best-Practices.md ├── cURL.md ├── SauceLabs.md ├── Test-Automation:-Learning-Resources.md ├── JavaScript:-Tools.md ├── Debugging-Node-Application.md ├── Node-Modules.md ├── Codecept:-Frequently-Performed-Tasks.md ├── JavaScript:-How-to's.md ├── Tips-&-Tricks.md ├── Codecept.md ├── Common-CLI-Commands.md ├── JavaScript:-Utility-Libraries.md ├── Free-Public-RESTful-JSON-APIs.md ├── Creating-Documentation.md ├── Node:-Common-Commands.md ├── Browser-Compatibility-Issues-from-new-ES6-Syntax.md ├── Git-Common-Commands.md ├── Docker:-Frequently-Used-Commands.md ├── Codecept:-Handling-Cookies.md ├── JavaScript:-Learning-Resources.md ├── Node.js-Setup.md ├── Working-with-Environment-Variables-in-Node.JS.md ├── How-to-Convert-ES6-into-ES5-using-Babel.md ├── Working-with-Z-Shell-(zsh).md ├── JavaScript:-Classes.md ├── JavaScript:-Fetch-API.md ├── Git-How-to's.md ├── JavaScript:-Modules.md ├── Making-an-HTTP-Request-or-REST-API-call-in-Node-JS.md ├── Docker-:-The-Basics.md ├── JavaScript:-Objects.md ├── Node-Package-Manager.md ├── README.md ├── JavaScript:-Iteration-Methods.md └── JavaScript-Quick-Reference.md ├── .DS_Store ├── images ├── header.png ├── docker-image-size.png ├── course-title-agile-pyramid.png ├── course-roadmap-automationdev.png └── course-title-agile-pyramid-2.png ├── _config.yml ├── README.md └── zshrc (sample-settings) /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arkhangelsk/Learning-Grid/HEAD/.DS_Store -------------------------------------------------------------------------------- /images/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arkhangelsk/Learning-Grid/HEAD/images/header.png -------------------------------------------------------------------------------- /docs/Setting-up-you-mac-machine.md: -------------------------------------------------------------------------------- 1 | * [Setting up your MAC machine](https://sourabhbajaj.com/mac-setup/) -------------------------------------------------------------------------------- /images/docker-image-size.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arkhangelsk/Learning-Grid/HEAD/images/docker-image-size.png -------------------------------------------------------------------------------- /docs/Learning-Resources-That-Rocks!.md: -------------------------------------------------------------------------------- 1 | * [Alan Simpson](http://alansimpson.me/) 2 | * [Flavio Copes](https://flaviocopes.com/) -------------------------------------------------------------------------------- /images/course-title-agile-pyramid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arkhangelsk/Learning-Grid/HEAD/images/course-title-agile-pyramid.png -------------------------------------------------------------------------------- /images/course-roadmap-automationdev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arkhangelsk/Learning-Grid/HEAD/images/course-roadmap-automationdev.png -------------------------------------------------------------------------------- /images/course-title-agile-pyramid-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arkhangelsk/Learning-Grid/HEAD/images/course-title-agile-pyramid-2.png -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman 2 | 3 | title: [Software Testing Trends] 4 | description: [Knowledge Centre for Software Testing Professionals] 5 | -------------------------------------------------------------------------------- /docs/Tools-&-Frameworks.md: -------------------------------------------------------------------------------- 1 | 1. [CodeceptJS](https://github.com/arkhangelsk/Learning-Grid/wiki/Codecept) 2 | 2. [Saucelabs](https://github.com/arkhangelsk/Learning-Grid/wiki/SauceLabs) 3 | -------------------------------------------------------------------------------- /docs/JavaScript:-Best-Practices.md: -------------------------------------------------------------------------------- 1 | * Avoid defining variables in the global scope. 2 | * Avoid reusing the same variable name twice. 3 | * Define variables in block scope. It will save memory in your code as it will cease to exist after the block finishes running. -------------------------------------------------------------------------------- /docs/cURL.md: -------------------------------------------------------------------------------- 1 | **cURL:** 2 | 3 | [cURL](https://curl.haxx.se/) - command line tool and library for transferring data with URLs 4 | 5 | Basic Syntax: 6 | ``` 7 | cUrl -i url 8 | ``` 9 | 10 | Want to learn more? Check out free open source book on curl: [Everything curl](https://curl.haxx.se/book.html) -------------------------------------------------------------------------------- /docs/SauceLabs.md: -------------------------------------------------------------------------------- 1 | ## References: 2 | 3 | * [Sauce Lab platform configurator](https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/) 4 | * [Sauce Labs test configuration options](https://wiki.saucelabs.com/display/DOCS/Test+Configuration+Options) 5 | * [Best practices for running automation test from Sauce Labs](https://wiki.saucelabs.com/display/DOCS/Best+Practices+for+Running+Tests) -------------------------------------------------------------------------------- /docs/Test-Automation:-Learning-Resources.md: -------------------------------------------------------------------------------- 1 | [Test Automation University - Webinar by Angie Jones](https://applitools.com/blog/test-automation-u-sneak-peek-with-angie-jones) 2 | 3 | [Learning Resources by UltimateQA](https://www.ultimateqa.com/resources/) 4 | 5 | [JavaScript, NodeJS & other notes by Flavio](https://flaviocopes.com/) 6 | 7 | [Book: Automate the Boring Stuff](https://automatetheboringstuff.com/) -------------------------------------------------------------------------------- /docs/JavaScript:-Tools.md: -------------------------------------------------------------------------------- 1 | * [JSBin](https://jsbin.com) - A live pastebin for HTML, CSS & JavaScript and a range of processors, including SCSS, CoffeeScript, Jade and more... 2 | * [Babel REPL](https://babeljs.io/repl/) - Check how your ES6 code transpiles to ES5 3 | * [Codepen](https://codepen.io/) - A social development environment for front-end designers and developers for testing and showcasing mixes of HTML, CSS, and JavaScript. 4 | 5 | -------------------------------------------------------------------------------- /docs/Debugging-Node-Application.md: -------------------------------------------------------------------------------- 1 | ## Debugging Node application using Chrome DevTools 2 | 3 | **Step 1:** Run below command to debug your node file. Once you run the command,it will start debugging utility. 4 | 5 | > node --inspect-brk filename.js 6 | 7 | **Step 2:** When the debugging utility has started, go to chrome and write chrome://inspect 8 | 9 | It will show the node process listed under target 10 | 11 | **Step 3:** Click on 'inspect'. It will show chrome dev tools working for your node script. -------------------------------------------------------------------------------- /docs/Node-Modules.md: -------------------------------------------------------------------------------- 1 | ## Node Module Wrapper Function 2 | 3 | `(function (exports, require, module, __filename, __dirname) { ` 4 | `});` 5 | 6 | This is an IIFE (Immediately Invoked Function Expression). Code in a (Node)file is wrapped inside this particular function. When someone requires this file, IIFE runs automatically and provides objects such as module.exports, exports, __dirname, __filename. These objects are not global but local to the module (file). 7 | 8 | Reference: https://nodejs.org/api/modules.html#modules_the_module_wrapper -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Check out WIKI: https://github.com/arkhangelsk/Learning-Grid/wiki 2 | 3 | Learning Grid GitHub Pages: https://arkhangelsk.github.io/Learning-Grid/ 4 | 5 | Tech Journal: https://arkhangelsk.github.io/TechJournal/ 6 | 7 | Tech Journal Redesigned: https://softwaretestingtrends.github.io/tech-journal/blog/ 8 | 9 | Productivity Journal: https://softwaretestingtrends.github.io/productivity-journal/ 10 | 11 | Portfolio: https://arkhangelsk.github.io/AdventuresInLearning/ 12 | 13 | The Recipe Center: https://arkhangelsk.github.io/TheRecipeCenter/ 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/Codecept:-Frequently-Performed-Tasks.md: -------------------------------------------------------------------------------- 1 | ## How to pass custom parameters through CLI? 2 | 3 | You can pass your parameters through CLI and then use them in your code via an environment variable. For example, you can use the variable declared below as process.env.TARGET_ENV in your code. 4 | 5 | ```javascript 6 | 7 | //Setting variable through CLI 8 | TARGET_ENV=prod ./node_modules/.bin/codeceptjs run tests/restServiceTest.js --config=puppeteer.conf.js --steps 9 | 10 | //How to use in code 11 | const apidata = require(`../data/data-${process.env.TARGET_ENV}`); 12 | ``` -------------------------------------------------------------------------------- /docs/JavaScript:-How-to's.md: -------------------------------------------------------------------------------- 1 | ## How to dynamically access object property using a variable? 2 | 3 | ``` 4 | const serviceName = 'GeoLoc'; 5 | const _baseURI = `baseURI${serviceName}`; 6 | const _path = `path${serviceName}`; 7 | const _header = `header${serviceName}`; 8 | 9 | const baseURI = apidata[_baseURI]; 10 | const path = apidata[_path]; 11 | const header = apidata[_header]; //here we want to get data apidata.headerGeoLoc 12 | 13 | let postParam = { 14 | header: header, 15 | endpoint: baseURI + path 16 | } 17 | ``` -------------------------------------------------------------------------------- /docs/Tips-&-Tricks.md: -------------------------------------------------------------------------------- 1 | ## See folder structure as tree on your mac: 2 | 3 | Install tree app using Homebrew: 4 | ``` 5 | brew install tree 6 | ``` 7 | 8 | run `tree` on the terminal to see the complete folder structure. You can limit the recursion by passing a -L flag and specifying the maximum depth. 9 | 10 | ``` 11 | tree 12 | 13 | tree -L 2 14 | ``` 15 | 16 | ## Use ack to search your code 17 | 18 | Install ack app using Homebrew: 19 | ``` 20 | brew install ack 21 | ``` 22 | 23 | **How to use:** 24 | ``` 25 | ack [OPTION]... PATTERN [FILES OR DIRECTORIES] 26 | 27 | ack --js sauce 28 | ``` 29 | -------------------------------------------------------------------------------- /docs/Codecept.md: -------------------------------------------------------------------------------- 1 | * [Handling Cookies](https://github.com/arkhangelsk/Learning-Grid/wiki/Codecept:-Handling-Cookies) 2 | * [Performed Tasks](https://github.com/arkhangelsk/Learning-Grid/wiki/Codecept:-Frequently-Performed-Tasks) 3 | 4 | *** 5 | 6 | ## References 7 | * [Codecept Quick Start](https://codecept.io/quickstart/) 8 | * [Introduction to CodeceptJS - free webinar from founders](https://www.youtube.com/watch?v=LjqMBYLiyC4&t=74s) 9 | * [Acceptance testing with codeceptJS](http://codenroll.it/post/acceptance-testing-with-codecept-js/) 10 | 11 | **Sample Git Repos:** 12 | 13 | https://github.com/jploskonka/testing-with-codeceptjs/tree/v3.0.0 -------------------------------------------------------------------------------- /docs/Common-CLI-Commands.md: -------------------------------------------------------------------------------- 1 | `echo $SHELL` -> to figure out which shell you are running. 2 | 3 | `Command + K` -> to clear your command line history 4 | 5 | `command+R`-> to get to a clear screen without losing command history 6 | 7 | `ls -l` -> List all the file details 8 | 9 | `~` -> Go to the home directory 10 | 11 | `open JavaScript` -> Open a folder 12 | 13 | `Ctrl+R` -> Allows to search for recently typed commands 14 | 15 | ## Setting up environment Variable: 16 | 17 | In order to set an environment variable, use the export command in the following format: 18 | 19 | ``` 20 | export KEY=value 21 | ``` 22 | Note: This would only set this for your current session. 23 | -------------------------------------------------------------------------------- /docs/JavaScript:-Utility-Libraries.md: -------------------------------------------------------------------------------- 1 | ## Lodash 2 | * [10 Lodash functions everyone should know](https://medium.com/voobans-tech-stories/10-lodash-functions-everyone-should-know-334b372aec5d) 3 | * [Lodash: 10 Javascript Utility Functions That You Should Probably Stop Rewriting](https://colintoh.com/blog/lodash-10-javascript-utility-functions-stop-rewriting) 4 | * [Don’t depend on Lodash when JavaScript has the same — Part 1](https://codeburst.io/dont-depend-on-lodash-when-javascript-has-the-same-part-1-52719420ee43) 5 | * [10 Lodash Features You Can Replace with ES6](https://www.sitepoint.com/lodash-features-replace-es6/) 6 | * [Why You shouldn’t use lodash anymore and use pure JavaScript instead](https://codeburst.io/why-you-shouldnt-use-lodash-anymore-and-use-pure-javascript-instead-c397df51a66) 7 | 8 | *** 9 | -------------------------------------------------------------------------------- /docs/Free-Public-RESTful-JSON-APIs.md: -------------------------------------------------------------------------------- 1 | **Reqres:** https://reqres.in/ 2 | 3 | **Toddmotto public APIs:** 4 | https://github.com/toddmotto/public-apis/blob/master/README.md 5 | 6 | **Mashape:** https://market.mashape.com/ 7 | 8 | **Programmableweb:** https://www.programmableweb.com/apis 9 | 10 | **DreamFactory:** https://github.com/dreamfactorysoftware/dreamfactory 11 | 12 | **Weather API:** https://openweathermap.org/api 13 | 14 | **Datamuse - API is a word-finding query engine:** https://www.datamuse.com/api/ 15 | 16 | **Random User Generator:** https://randomuser.me/ 17 | 18 | **JSON and XML Weather API and Geo Developer API:** https://www.apixu.com/ 19 | 20 | **FourSquare Places API:** https://developer.foursquare.com/docs/api 21 | 22 | **Link Shortening API - Rebrandly** https://www.rebrandly.com/ 23 | 24 | 25 | -------------------------------------------------------------------------------- /docs/Creating-Documentation.md: -------------------------------------------------------------------------------- 1 | * [Writing & Formatting on Github](https://help.github.com/categories/writing-on-github/) 2 | * [Github Pages](https://pages.github.com/) - Creating websites for you & your projects directly from your github repository. 3 | * [Free Course: Easy Markdown with VS Code by Alan Simpson](http://alansimpson.thinkific.com/courses/easy-markdown-with-vs-code) 4 | * [An npm module to create better documentation](https://github.com/pedronauck/docz) 5 | * [Stack Overflow: Effortless export from github wiki](https://stackoverflow.com/questions/18759738/effortless-export-from-github-wiki) 6 | * [Have you ever tried to convert Github Wiki into PDF?](https://medium.com/@yakivmospan/did-you-ever-try-to-convert-github-wiki-in-pdf-c3078538bf12) 7 | * [GitBook](https://www.gitbook.com/?t=1) - Creating documentation in book format 8 | 9 | -------------------------------------------------------------------------------- /docs/Node:-Common-Commands.md: -------------------------------------------------------------------------------- 1 | ## General Commands: 2 | 3 | `npm init` — Creates a package.json file. 4 | 5 | `npm install` — Installs Node packages 6 | 7 | ## Timer Commands: 8 | 9 | https://nodejs.org/en/docs/guides/timers-in-node/ 10 | 11 | ## Node CLI 12 | 13 | https://nodejs.org/api/cli.html 14 | 15 | **Examples:** 16 | 17 | `node -p "os.cpus().length"` 18 | 19 | `node -p "process.versions.v8"` 20 | 21 | Check the full list of available options by using below command: 22 | 23 | `node -h | less` 24 | 25 | ## Process Object - Node built-in bridge to the O/S 26 | 27 | https://nodejs.org/api/process.html 28 | 29 | **Examples:** 30 | 31 | `process.env.USER` 32 | 33 | Note: Process environment value can be passed through the command line or by exporting as an environment variable. 34 | 35 | ## Resources: 36 | 37 | https://github.com/jscomplete/ngs -------------------------------------------------------------------------------- /docs/Browser-Compatibility-Issues-from-new-ES6-Syntax.md: -------------------------------------------------------------------------------- 1 | The new ES6 syntax has greatly improved readability and efficiency of JavaScript but the ES6 syntax is not supported by most web browsers, so developers often run into browser compatibility issues. 2 | 3 | There are different ways to handle these issues: 4 | 5 | * caniuse.com — This site provides data on web browser compatibility for HTML, CSS, and JavaScript. This site also allows checking browser support on a feature-by-feature basis. 6 | * Babel — A Javascript library that is used to convert unsupported JavaScript (ES6) into an old version of JavaScript (ES5) that is recognized by most modern browsers. This conversion is called transpilation. 7 | 8 | Check out: [How to Convert ES6 into ES5 using Babel](https://github.com/arkhangelsk/Learning-Grid/wiki/How-to-Convert-ES6-into-ES5-using-Babel) 9 | 10 | -------------------------------------------------------------------------------- /docs/Git-Common-Commands.md: -------------------------------------------------------------------------------- 1 | `git --version` Checking installed git version 2 | 3 | `git config user.name` Checking Configuration - Name 4 | 5 | `git config user.email` Checking Configuration - Email 6 | 7 | `git config --list` List existing configuration 8 | 9 | `git status` To check current status of Git repository 10 | 11 | `git remote` Checking remote (i.e origin. Origin is where the repo is located on Github) 12 | 13 | `git remote -v` Checking more details about remote 14 | 15 | `git init` Initializing a new repo 16 | 17 | `git add .` To add all files to staging on local machine 18 | 19 | `git commit -m "Commit"` Adding commit 20 | 21 | `git log` Log of all file changes 22 | 23 | `git config --global alias.s status` Defining alias 24 | 25 | `git diff` Shows if there are changes in file 26 | 27 | `git push` To push the changes 28 | 29 | `git add -am "Comment"` Add and comment a file 30 | -------------------------------------------------------------------------------- /docs/Docker:-Frequently-Used-Commands.md: -------------------------------------------------------------------------------- 1 | **Check version of docker installation:** 2 | ``` 3 | docker --version 4 | docker-compose --version 5 | docker-machine --version 6 | ``` 7 | 8 | **Check if your docker installation is working:** 9 | ``` 10 | docker run hello-world 11 | ``` 12 | **View the list of running containers:** 13 | 14 | ``` 15 | docker container ls 16 | ``` 17 | or 18 | ``` 19 | docker ps 20 | ``` 21 | 22 | **View the list of all (running & stopped) containers:** 23 | ``` 24 | docker container ls -a 25 | ``` 26 | 27 | **Stop Container:** 28 | ``` 29 | docker container stop container-name 30 | ``` 31 | 32 | **Remove Container:** 33 | ``` 34 | docker container rm container-name 35 | ``` 36 | 37 | **List docker images:** 38 | ``` 39 | docker image ls 40 | ``` 41 | 42 | **Remove docker image:** 43 | ``` 44 | docker image rm image-repository 45 | ``` 46 | 47 | **Search docker repository for your desired container:** 48 | ``` 49 | docker search puppeteer 50 | ``` -------------------------------------------------------------------------------- /docs/Codecept:-Handling-Cookies.md: -------------------------------------------------------------------------------- 1 | ### Configuration 2 | 3 | keepCookies: (optional, default: false) - keep cookies between tests when restart set to false. 4 | 5 | ### WebdriverIO & Puppeteer 6 | 7 | **clearCookie:** Clears a cookie by name, if none provided clears all cookies. 8 | ``` 9 | I.clearCookie(); 10 | I.clearCookie('myCookie'); 11 | ``` 12 | 13 | **dontSeeCookie:** Checks that cookie with the given name does not exist. 14 | ``` 15 | I.dontSeeCookie('userID'); 16 | ``` 17 | 18 | **grabCookie:** Gets a cookie object by name. If none provided gets all cookies. 19 | ``` 20 | let cookie = await I.grabCookie('lang'); 21 | assert(cookie.value, 'en'); 22 | ``` 23 | 24 | **seeCookie:** Checks that cookie with given name exists. 25 | ``` 26 | I.seeCookie('userID'); 27 | ``` 28 | 29 | **setCookie:** Sets a cookie. 30 | ``` 31 | I.setCookie({name: 'auth', value: true}); 32 | ``` 33 | 34 | *** 35 | **References:** 36 | https://codecept.io/helpers/WebDriverIO/ 37 | https://codecept.io/helpers/ -------------------------------------------------------------------------------- /docs/JavaScript:-Learning-Resources.md: -------------------------------------------------------------------------------- 1 | ## Learning Resources 2 | 3 | * ["You Don't Know JS" (book series) by Kyle Simpson ](https://github.com/getify/You-Dont-Know-JS) 4 | * [Tutorials by Flavio (JavaScript, NodeJS, Git, DevTools, Services etc.)](https://flaviocopes.com/) 5 | * [11 JavaScript Utility Libraries you Should Know in 2019](https://blog.bitsrc.io/11-javascript-utility-libraries-you-should-know-in-2018-3646fb31ade) 6 | * [A Practical Guide to Regular Expressions (RegEx) In JavaScript](https://blog.bitsrc.io/a-beginners-guide-to-regular-expressions-regex-in-javascript-9c58feb27eb4) 7 | * [Keep Code Consistent Across Developers The Easy Way — With Prettier & ESLint](https://itnext.io/keep-code-consistent-across-developers-the-easy-way-with-prettier-eslint-60bb7e91b76c) 8 | * [State of JavaScript 2018 Survey](https://2018.stateofjs.com/introduction) 9 | * [BestofJS.org](https://bestofjs.org) 10 | * [30 Day Vanilla JS Coding Challenge by Wes Bos](https://javascript30.com/) 11 | * [Learn JavaScript - Alan Simpson](https://alansimpson.me/javascript/videos/) -------------------------------------------------------------------------------- /docs/Node.js-Setup.md: -------------------------------------------------------------------------------- 1 | ## Check Node Installation & install Path: 2 | 3 | **Install Node:** 4 | 5 | > $brew install node 6 | 7 | **Upgrade Node Version:** 8 | 9 | > $brew upgrade node 10 | 11 | **Check Node/npm/npx version:** 12 | 13 | > $node -v 14 | 15 | > $npm -v 16 | 17 | > $npx -v 18 | 19 | **Check Node/npm/npx installation path:** 20 | 21 | > $which node 22 | 23 | > $which npm 24 | 25 | > $which npx 26 | 27 | ## REPL: 28 | 29 | **Open Node REPL:** 30 | 31 | > $node 32 | 33 | **Open multi-line editor in REPL:** 34 | 35 | > $.editor 36 | 37 | **Check commands available in REPL:** 38 | 39 | > $.help 40 | 41 | ## Check if your version of node supports modern JavaScript: 42 | Start node in REPL mode and type below line of code in node interactive session. If you get an error, means you need to upgrade your node version: 43 | 44 | **Modern JS Test:** 45 | 46 | > (async (a = 1, ...b) => ({ ...b, a, [a]: `${a}` }))() 47 | 48 | **New Promise APIs:** 49 | 50 | > util.promisify 51 | 52 | > require('fs').promises 53 | 54 | Ref: https://gist.github.com/samerbuna/8d9d36576df425181e70e50b3cb35f3a 55 | 56 | -------------------------------------------------------------------------------- /docs/Working-with-Environment-Variables-in-Node.JS.md: -------------------------------------------------------------------------------- 1 | ## Accessing environment variables in Node.js 2 | 3 | Accessing environment variables in Node.js is supported right out of the box and you can use below command to see what environment variables are available to your node application. 4 | 5 | ```javascript 6 | console.log(process.env); 7 | ``` 8 | 9 | You can access a specific environment variable using below command: 10 | ``` 11 | console.log('PATH: ', process.env.PATH); 12 | ``` 13 | 14 | ## Using .env file to specify environment variables for your application 15 | 16 | **What is a .env file? ** 17 | 18 | It’s a file used inside your project to specify environment variables. To read variables from .env file, you need Dotenv that is is a zero-dependency module that loads environment variables from a .env file into process.env. 19 | 20 | Step 1: Create an .env file and add your required variable. 21 | ``` 22 | ENVIRONMENT = QA2 23 | ``` 24 | 25 | Step 2: Use the defined variable in your desired file. 26 | 27 | **Sample Code:** 28 | ```javascript 29 | require('dotenv').config(); 30 | console.log('Your environment variable ENVIRONMENT has the value: ', process.env.ENVIRONMENT); 31 | ``` 32 | Output: 33 | ``` 34 | Your environment variable ENVIRONMENT has the value: QA2 35 | ``` 36 | 37 | ## Resources: 38 | https://www.twilio.com/blog/2017/08/working-with-environment-variables-in-node-js.html 39 | https://github.com/yatki/read-env 40 | https://github.com/recursivefunk/good-env 41 | https://github.com/tkalfigo/dotenvenc 42 | -------------------------------------------------------------------------------- /docs/How-to-Convert-ES6-into-ES5-using-Babel.md: -------------------------------------------------------------------------------- 1 | Use babel npm package to transpile your ES6 to ES5 2 | 3 | 1. Setup your project to use npm by running `npm init` command. This will create a package.json file in the root directory 4 | 2. install babel required packages 5 | 6 | ``` 7 | npm install --save-dev @babel/core @babel/cli @babel/preset-env @babel/node 8 | ``` 9 | 10 | * babel-cli package includes command line Babel tools 11 | * babel-preset-env package has the code that maps ES6 and above (ES6+), to ES5 12 | 13 | 3. Create .babelrc file. Inside .babelrc you need to define the preset for your source JavaScript file. To specify that you are transpiling code from an ES6+ source, add the following code into .babelrc: 14 | 15 | ``` 16 | { 17 | "presets": ["@babel/preset-env"] 18 | } 19 | ``` 20 | 21 | 4. Create a npm build script using the babel command in package.json 22 | 23 | 24 | ``` 25 | "scripts": { 26 | "build": "babel src -d build" 27 | ``` 28 | 29 | The babel command takes two arguments: the path to your ES6 code and a path where you want your ES5 code to be placed. 30 | 31 | Adding the -d flag to the command instructs Babel to write the transpiled code to a directory. In above example, ES6 code is in src directory and babel writes the transpiled code into 'build' directory. 32 | 33 | 5. Run the npm command 34 | 35 | ``` 36 | npm run build 37 | ``` 38 | 39 | Now you'll see your converted JavaScript files in the build directory. 40 | 41 | Reference: 42 | 43 | [Convert ES6 into ES5 using Babel](https://medium.com/@SunnyB/how-to-convert-es6-into-es5-using-babel-1b533d31a169) 44 | 45 | -------------------------------------------------------------------------------- /docs/Working-with-Z-Shell-(zsh).md: -------------------------------------------------------------------------------- 1 | ## Install iTerm2: 2 | https://iterm2.com/downloads.html 3 | 4 | ## Install ZSH: 5 | https://ohmyz.sh/ 6 | 7 | ## Setting up custom profile: 8 | iTerm2 -> Preferences -> Profiles -> Add new profile -> Set as default profile 9 | 10 | ### Recommended Theme: https://github.com/wesbos/Cobalt2-iterm 11 | Under the Colors tab import the cobalt2.itermcolors file via the Load Presets drop-down. 12 | Open up your ZSH preferences at ~/.zshrc and change the theme variable to ZSH_THEME=cobalt2 13 | open file using: nano ~/.zshrc 14 | 15 | Or use powerlevel9k: https://github.com/bhilburn/powerlevel9k 16 | https://medium.com/@alex285/get-powerlevel9k-the-most-cool-linux-shell-ever-1c38516b0caa 17 | 18 | ### Powerline Fonts: https://github.com/powerline/fonts 19 | ### Recommended: Inconsolata 20 | git clone https://github.com/powerline/fonts 21 | cd fonts 22 | ./install.sh 23 | 24 | Access the Preferences pane on the Profiles tab -> Under the Text tab change the font for each type (Regular and Non-ASCII) to 'Inconsolata for Powerline'. 25 | 26 | ## Jump around folders using z: 27 | https://github.com/rupa/z 28 | 29 | ## Install trash: 30 | npm install --global trash-cli 31 | 32 | ## Setting up plugins: 33 | Open .zshrc file to setup plugins: 34 | nano ~/.zshrc 35 | 36 | ## Folder with ZSH Themes & Templates: 37 | open ~/.oh-my-zsh 38 | 39 | ## A video series on learning modern command line: 40 | https://commandlinepoweruser.com/ 41 | 42 | ## ZSH supported Command: 43 | take test1 -> creates a folder and then cd to that newly created folder 44 | 45 | **Sample .zshrc** 46 | 47 | [Sample .zshrc](https://github.com/arkhangelsk/STT-Notes/blob/master/zshrc%20(sample-settings)) 48 | 49 | 50 | -------------------------------------------------------------------------------- /docs/JavaScript:-Classes.md: -------------------------------------------------------------------------------- 1 | ## How to create a class: 2 | * Classes are templates for JavaScript objects. 3 | * A constructor method is called when we create a new instance of a class. 4 | 5 | ```javascript 6 | class Employee { 7 | constructor(name, department) { 8 | this.name = name; 9 | this.department = department; 10 | } 11 | } 12 | 13 | const emp1 = new Employee('Tom', 'IT'); 14 | console.log(emp1.name); 15 | ``` 16 | **output:** 17 | ``` 18 | "Tom" 19 | ``` 20 | 21 | ## Inheritance: 22 | * A child class can inherit the properties and methods from a parent class. 23 | * The **extends** keyword is used when we create a subclass from the parent class. 24 | * The super keyword calls the constructor() of a parent class. 25 | * Static methods are always called on the class, but not on instances of the class. 26 | 27 | ```javascript 28 | class Employee { 29 | constructor(name) { 30 | this._name = name; 31 | this._totalVacationDays = 20; 32 | } 33 | 34 | get name() { 35 | return this._name; 36 | } 37 | 38 | get totalVacationDays() { 39 | return this._totalVacationDays; 40 | } 41 | 42 | static generateTempPassword(){ 43 | return Math.floor(Math.random()*100000); 44 | } 45 | } 46 | 47 | class Accountant extends Employee { 48 | constructor(name, education) { 49 | super(name); 50 | this._education = education; 51 | } 52 | 53 | get educationInfo() { 54 | return this._education; 55 | } 56 | } 57 | 58 | const accountant1 = new Accountant('Tom', 'Masters'); 59 | 60 | console.log(accountant1.totalVacationDays); 61 | console.log(Employee.generateTempPassword()); 62 | 63 | ``` 64 | 65 | **output:** 66 | ``` 67 | 20 68 | 7452 //generates any random number between 0 and 100000 69 | ``` -------------------------------------------------------------------------------- /docs/JavaScript:-Fetch-API.md: -------------------------------------------------------------------------------- 1 | ## Using JavaScript fetch() to make GET and POST requests: 2 | 3 | **Get Request:** 4 | 5 | * Fetch API is a replacement for XMLHttpRequest 6 | * It is a web API that can be used to create requests. 7 | * Once fetch is called, it will return promises. 8 | * To handle promises returned by fetch(), we chain .then() methods 9 | * The .json() method converts a returned promise to a JSON object. 10 | 11 | ```javascript 12 | fetch('https://api-url-goes-here.com/endpoint').then(response => { 13 | if(response.ok){ 14 | return response.json(); 15 | } 16 | throw new Error('Request failed!'); 17 | }, networkError => { 18 | console.log(networkError.message); 19 | }).then(jsonResponse => { 20 | return jsonResponse; 21 | }); 22 | ``` 23 | 24 | **Post Request:** 25 | 26 | Fetch POST call takes two arguments 27 | 1. An endpoint of the API 28 | 2. An object that contains information needed for the POST request 29 | 30 | ```javascript 31 | fetch('https://api-url-goes-here.com/endpoint', { 32 | method: 'POST', 33 | body: JSON.stringify({id: '200'}) 34 | }).then(response => { 35 | if(response.ok){ 36 | return response.json(); 37 | } 38 | throw new Error('Request failed!'); 39 | }, networkError => { 40 | console.log(networkError.message); 41 | }).then(jsonResponse => { 42 | return jsonResponse; 43 | }); 44 | ``` 45 | 46 | **async/await Get Request:** 47 | 48 | ```javascript 49 | const getData = async () => { 50 | try { 51 | const response = await fetch('https://api-url-goes-here.com/endpoint'); 52 | if(response.ok){ 53 | const jsonResponse = await response.json(); 54 | return jsonResponse; 55 | } 56 | throw new Error('Request failed!'); 57 | } catch (error){ 58 | console.log(error); 59 | } 60 | } 61 | ``` 62 | 63 | **async/await Post Request:** 64 | 65 | ```javascript 66 | const getData = async () => { 67 | try{ 68 | const response = await fetch('https://api-url-goes-here.com/endpoint', { 69 | method: 'POST', 70 | body: JSON.stringify({id: 200}) 71 | }); 72 | if (response.ok){ 73 | const jsonResponse = await response.json(); 74 | return jsonResponse; 75 | } 76 | throw new Error('Request failed!'); 77 | } catch (error){ 78 | console.log(error); 79 | } 80 | } 81 | ``` 82 | -------------------------------------------------------------------------------- /docs/Git-How-to's.md: -------------------------------------------------------------------------------- 1 | ## How to's: 2 | 3 | ### How to create a new branch? 4 | 5 | `git checkout -b feature_branch_name` 6 | 7 | Note: First make sure your repository is up to date with the latest commit on master using `git pull origin master`. git pull does a git fetch followed by a git merge to update the local repo with the remote repo. 8 | 9 | ### How to create a new brach from an existing branch? 10 | 11 | `git checkout -b feature_branch_name base-branch-name` 12 | 13 | ### How to commit changes? 14 | After editing the files, add and commit your changes: 15 | 16 | `git add .` to add all changes 17 | 18 | `git commit -m "Comment text"` 19 | 20 | Or `git add ` to add only a particular file. 21 | 22 | or `git commit -am "Your message"` to add and comment as single action. 23 | 24 | ### How to push code to repo? 25 | 26 | `git push -u origin feature_branch_name` 27 | 28 | ### How to list all remote branches in Git? 29 | 30 | `git branch -r` or 31 | 32 | `git ls-remote` or 33 | 34 | `git ls-remote --heads` command will list all branches available on the remote repository 35 | 36 | You can also do `git ls-remote [url]` if you don't want to clone the repo first. 37 | 38 | **Note:** typing q should get you out of the listing mode generated by the git. 39 | 40 | ### How to create a pull request? 41 | 42 | 1. After pushing your local changes to your remote repository, point your browser to your repository on Github 43 | 2. Click the Pull Requests tab. 44 | 3. Click New pull request. 45 | 4. In the base: dropdown, select master . 46 | 5. In the compare: dropdown, select the branch you recently pushed to the repository. 47 | 48 | Learn more: [https://yangsu.github.io/pull-request-tutorial/](https://yangsu.github.io/pull-request-tutorial/) 49 | 50 | 51 | *** 52 | 53 | ## Creating Github Documentation 54 | 55 | [Writing & Formatting on Github](https://help.github.com/categories/writing-on-github/) 56 | 57 | [Github Pages](https://pages.github.com/) - Creating websites for you & your projects directly from your github repository. 58 | 59 | [GitBook](https://www.gitbook.com/?t=1) - Creating documentation in book format 60 | 61 | *** 62 | 63 | ## Resources: 64 | [Git Tutorial](http://try.github.io/) 65 | 66 | [Git Cheat Sheet](https://services.github.com/on-demand/downloads/github-git-cheat-sheet/) 67 | -------------------------------------------------------------------------------- /docs/JavaScript:-Modules.md: -------------------------------------------------------------------------------- 1 | ## module.exports 2 | 3 | * 'module' is a variable that represents the module, and 'exports' exposes the module as an object. 4 | 5 | 6 | ```javascript 7 | let Book = {}; 8 | Book.JavaScript = "You Don't know JS"; 9 | module.exports = Book; 10 | ``` 11 | 12 | 13 | * module.exports can expose the current module as an object. You can do this by wrapping any collection of data and functions in an object, and exporting the object using module.exports 14 | 15 | 16 | ```javascript 17 | module.exports = { 18 | javascript: "You Don't know JS", 19 | getJavaScript: function(){ 20 | return this.javascript; 21 | } 22 | }; 23 | ``` 24 | 25 | ## require 26 | 27 | require method imports the module for use in the current program. 28 | 29 | ```javascript 30 | const book1 = require('./book1'); 31 | const book2 = require('./book2'); 32 | ``` 33 | ## export default 34 | 35 | When using ES6 syntax, use export default in place of module.exports statement to export JavaScript objects, functions, and primitive data types. 36 | 37 | 38 | ```javascript 39 | let Car = {}; 40 | 41 | export default Car; 42 | ``` 43 | 44 | ## import 45 | 46 | In ES6 syntax, module introduces the import keyword for importing objects. 47 | 48 | 49 | ```javascript 50 | import Car from './car'; 51 | ``` 52 | 53 | In the above example Car specifies the name of the variable to store the default export in. If you are working with local files, no extension is required with the name of the file. 54 | 55 | ## Named Exports 56 | 57 | In ES6, we can also use named exports that allow exporting data through the use of variables. 58 | 59 | 60 | ```javascript 61 | let colors = ''; 62 | 63 | function isWhite() { 64 | }; 65 | function isBlack() { 66 | }; 67 | 68 | export { colors, isWhite, isBlack}; 69 | ``` 70 | 71 | Named exports can also be exported by placing the keyword export in the beginning of the variable declaration statement. 72 | 73 | 74 | ```javascript 75 | export let colors = ''; 76 | 77 | export function isWhite() { 78 | }; 79 | function isBlack() { 80 | }; 81 | ``` 82 | 83 | ## Named Imports 84 | 85 | 86 | ```javascript 87 | import { isWhite, isBlack } from './colors'; 88 | 89 | console.log(isWhite); 90 | ``` 91 | 92 | ## Export as 93 | 94 | You can also change the name of variables when you export or import them. 95 | 96 | 97 | ```javascript 98 | let colors = ''; 99 | 100 | function isWhite() { 101 | }; 102 | function isBlack() { 103 | }; 104 | 105 | export { colors as colorChoices, isWhite, isBlack}; 106 | ``` 107 | 108 | ## Import as 109 | 110 | 111 | ```javascript 112 | import {isWhite as White} from './color'; 113 | ``` 114 | 115 | You can also import the entire module as an alias using 'as': 116 | 117 | 118 | ```javascript 119 | import * as Colors from './color'; 120 | 121 | Colors.colors; 122 | Colors.isWhite(); 123 | Colors.isBlack(); 124 | ``` 125 | 126 | ## Combining named exports and default export 127 | 128 | 129 | ```javascript 130 | let colors = ''; 131 | 132 | function isWhite() { 133 | }; 134 | function isBlack() { 135 | }; 136 | 137 | export {isWhite as White, isBlack as Black}; 138 | export default colors; 139 | ``` 140 | 141 | Similarly We can also exported some of the variables at declaration time and export others with the export default syntax. 142 | 143 | 144 | ```javascript 145 | let colors = ''; 146 | 147 | export function isWhite() { 148 | }; 149 | export function isBlack() { 150 | }; 151 | 152 | export default colors; 153 | 154 | ``` -------------------------------------------------------------------------------- /docs/Making-an-HTTP-Request-or-REST-API-call-in-Node-JS.md: -------------------------------------------------------------------------------- 1 | There are many ways available to send HTTP request or make a REST API call during acceptance testing: 2 | 3 | **1. HTTP - The standard library** 4 | * default HTTP module in the standard Node.js library. 5 | * No need to install any external dependency. 6 | * It is NOT very user-friendly compared to other solutions. 7 | * It does not parse the response data manually. 8 | * It does not support HTTPS by default, so you need to require the https module instead if required. 9 | 10 | **2. [Request](https://github.com/request/request) - Simplified HTTP client** 11 | * An easy to use library that deals with HTTP requests 12 | * For promise handling, use Bluebird or switch to request-promise library 13 | 14 | **3. [Codecept REST API Helper](https://codecept.io/helpers/REST/)** 15 | * This helper use unirest to perform requests. 16 | * Provides easy to understand DSL 17 | 18 | **4. [Unirest](http://unirest.io/nodejs.html)** 19 | * Lightweight HTTP Request Client library 20 | * Provides a cookie jar to store multiple cookies 21 | 22 | **5. [Axios](https://www.npmjs.com/package/axios)** 23 | * This is a promise based HTTP client for the browser and node.js 24 | * Make XMLHttpRequests from the browser 25 | * Make http requests from node.js 26 | * Supports the Promise API 27 | * Intercept request and response 28 | * Transform request and response data 29 | * Cancel requests 30 | * Automatic transforms for JSON data 31 | * Client-side support for protecting against XSRF 32 | * The request contains the following information: 33 | 34 | data: {},status, statusText, headers, config (the config that was provided to axios with request), request. 35 | 36 | **Resources:** 37 | 38 | [axios cheat sheet](https://kapeli.com/cheat_sheets/Axios.docset/Contents/Resources/Documents/index) 39 | 40 | [Getting started with axios tutorial](https://appdividend.com/2018/08/30/getting-started-with-axios-tutorial-example/) 41 | 42 | **6. [node-fetch](https://www.npmjs.com/package/node-fetch)** 43 | * A light-weight module that brings window.fetch to node.js 44 | * Stay consistent with window.fetch API. 45 | * Use native promise, but allow substituting it with other popular promise libraries like Bluebird 46 | * Use native Node streams for body, on both request and response. 47 | * Useful extensions such as timeout, redirect limit, response size limit, explicit errors for troubleshooting. 48 | 49 | **7. [request-promise](https://github.com/request/request-promise)** 50 | * Simplified HTTP request client [**'request'**](https://github.com/request/request) with Promise support. Powered by Bluebird. 51 | * request-promise wraps around request so everything that works with request also works with request-promise 52 | 53 | **8. [SuperAgent](https://github.com/visionmedia/superagent)** 54 | * Makes AJAX requests from the browser 55 | * Make http requests from node.js 56 | * Provides a function `query()` to add parameters to the request. 57 | * It parses the JSON response automatically. 58 | 59 | *** 60 | 61 | ### Cookie Handling: 62 | * [tough-cookie](https://www.npmjs.com/package/tough-cookie) 63 | 64 | 65 | *** 66 | 67 | ## References: 68 | 69 | https://www.twilio.com/blog/2017/08/http-requests-in-node-js.html 70 | 71 | https://codeburst.io/how-to-make-an-http-request-in-nodejs-http-mechanism-libraries-f25ec990d307 72 | 73 | [Why use Promise Libraries while Node.js has added native support for promises?](https://stackoverflow.com/questions/34960886/are-there-still-reasons-to-use-promise-libraries-like-q-or-bluebird-now-that-we) 74 | 75 | Learning Promises: 76 | https://scotch.io/tutorials/javascript-promises-for-dummies 77 | -------------------------------------------------------------------------------- /docs/Docker-:-The-Basics.md: -------------------------------------------------------------------------------- 1 | ## What is Docker? 2 | Docker is a system to create, deploy, and run applications by using containers. 3 | 4 | ## What is a Docker Image? 5 | A Docker Image is the template (application plus required binaries and libraries) needed to build a running Docker Container (the running instance of that image). 6 | 7 | As templates, images are what can be used to share a containerized applications. Collections of images are stored/shared in registries like Docker Hub. When you download an image, it can then be used (as a template) to spin up multiple running Containers in your own environment. 8 | 9 | ## What is a Docker Container? 10 | * A container is a runnable instance of an image. 11 | * A container is defined by its image as well as any configuration options you provide to it when you create or start it. 12 | 13 | **Reference:** 14 | 15 | https://docs.docker.com/engine/docker-overview/#docker-objects 16 | 17 | https://www.quora.com/What-are-Docker-Images 18 | 19 | ## What is the Dockerfile? 20 | 21 | * A Dockerfile list all the commands that user would normally execute manually in order to build a Docker image. 22 | * Docker reads the Dockerfile and executes those commands one-by-one and builds the target image. 23 | * To build an image using a Dockerfile, use below command: 24 | ``` 25 | docker build -f /path/to/Dockerfile 26 | ``` 27 | 28 | ## How to determine the size of a Docker image? 29 | Use command `docker images` to determine the size of the docker image (last column) 30 | 31 | ![docker-image-size](https://github.com/arkhangelsk/Learning-Grid/blob/master/images/docker-image-size.png) 32 | 33 | ## Creating your first docker container: 34 | 35 | https://www.jamescoyle.net/how-to/1503-create-your-first-docker-container 36 | 37 | https://www.vultr.com/docs/how-to-use-docker-creating-your-first-docker-container 38 | 39 | ## Setting up puppeteer environment with Docker: 40 | https://github.com/ebidel/try-puppeteer/tree/master/backend 41 | 42 | https://zwischenzugs.com/2017/10/16/puppeteer-headless-chrome-in-a-container/ 43 | 44 | https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker 45 | 46 | https://dev.to/ikeryo1182/constracting-puppeteer-environment-with-vagrant-and-docker-5ano 47 | 48 | *** 49 | 50 | ## Resources: 51 | 52 | Book: [Docker in Practice](https://www.manning.com/books/docker-in-practice-second-edition?a_aid=zwischenzugs&a_bid=550032fc) 53 | 54 | Article: [How to Dockerize your End-to-End acceptance tests](https://medium.freecodecamp.org/how-to-dockerize-your-end-to-end-acceptance-tests-dbb593acb8e0) 55 | 56 | Quora: [What is docker?](https://www.quora.com/qemail/track_click?al_imp=eyJ0eXBlIjogMzMsICJoYXNoIjogIjB8MTB8MXw2NDc2NDgyMCJ9&al_pri=ReadMoreLinkClickthrough&aoid=1EjNS7gFO2a&aoty=1&aty=4&click_pos=10&ct=1544738197431220&et=130&id=3db5a8fb14274d369619d549556aad9f&source=7&src=1&st=1544738197547871&stories=1_m5m85t9ONMK%7C1_ROMquNe97oK%7C1_qJ3zFPQjWCi%7C1_duVMKaAMwH1%7C1_LAjfv22RpYB%7C1_alUBLFEQmA8%7C1_V7JcvVDQTJi%7C1_IdWComB7OKu%7C1_VTSGzAkbwc2%7C1_1EjNS7gFO2a&ty=1&ty_data=1EjNS7gFO2a&uid=YsTkMQnEFdZ&v=0) 57 | 58 | Docker Learning Series: 59 | 60 | [Docker Series — What is Docker?](https://medium.com/pintail-labs/docker-series-what-is-docker-9eddca88f434) 61 | 62 | [Docker Series — Starting your first container](https://medium.com/pintail-labs/docker-series-starting-your-first-container-92dfd1dc859) 63 | 64 | [Docker Series — Creating your first Dockerfile](https://medium.com/pintail-labs/docker-series-creating-your-first-dockerfile-573bfea4991) 65 | 66 | [Docker Series — Building your first Docker image](https://medium.com/pintail-labs/docker-series-building-your-first-image-8a6f051ae637) 67 | 68 | [Docker Series — Moving past one container with Docker Compose](https://medium.com/pintail-labs/docker-series-moving-past-one-container-bf32b45831d3) 69 | 70 | [Docker Series — Cheat Sheet](https://medium.com/pintail-labs/docker-series-cheat-sheet-e1841961c61) 71 | 72 | -------------------------------------------------------------------------------- /zshrc (sample-settings): -------------------------------------------------------------------------------- 1 | # If you come from bash you might have to change your $PATH. 2 | # export PATH=$HOME/bin:/usr/local/bin:$PATH 3 | 4 | # Path to your oh-my-zsh installation. 5 | export ZSH="/Users/user-name/.oh-my-zsh" 6 | 7 | # Set name of the theme to load --- if set to "random", it will 8 | # load a random theme each time oh-my-zsh is loaded, in which case, 9 | # to know which specific one was loaded, run: echo $RANDOM_THEME 10 | # See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes 11 | ZSH_THEME="powerlevel9k/powerlevel9k" 12 | 13 | #customize the prompt using powerlevel9k 14 | POWERLEVEL9K_DISABLE_RPROMPT=true 15 | POWERLEVEL9K_PROMPT_ON_NEWLINE=true 16 | POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="▶ " 17 | POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="" 18 | 19 | #include z to jump around folders 20 | . ~/z.sh 21 | 22 | # Set list of themes to pick from when loading at random 23 | # Setting this variable when ZSH_THEME=random will cause zsh to load 24 | # a theme from this variable instead of looking in ~/.oh-my-zsh/themes/ 25 | # If set to an empty array, this variable will have no effect. 26 | # ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) 27 | 28 | # Uncomment the following line to use case-sensitive completion. 29 | # CASE_SENSITIVE="true" 30 | 31 | # Uncomment the following line to use hyphen-insensitive completion. 32 | # Case-sensitive completion must be off. _ and - will be interchangeable. 33 | # HYPHEN_INSENSITIVE="true" 34 | 35 | # Uncomment the following line to disable bi-weekly auto-update checks. 36 | # DISABLE_AUTO_UPDATE="true" 37 | 38 | # Uncomment the following line to change how often to auto-update (in days). 39 | # export UPDATE_ZSH_DAYS=13 40 | 41 | # Uncomment the following line to disable colors in ls. 42 | # DISABLE_LS_COLORS="true" 43 | 44 | # Uncomment the following line to disable auto-setting terminal title. 45 | # DISABLE_AUTO_TITLE="true" 46 | 47 | # Uncomment the following line to enable command auto-correction. 48 | # ENABLE_CORRECTION="true" 49 | 50 | # Uncomment the following line to display red dots whilst waiting for completion. 51 | # COMPLETION_WAITING_DOTS="true" 52 | 53 | # Uncomment the following line if you want to disable marking untracked files 54 | # under VCS as dirty. This makes repository status check for large repositories 55 | # much, much faster. 56 | # DISABLE_UNTRACKED_FILES_DIRTY="true" 57 | 58 | # Uncomment the following line if you want to change the command execution time 59 | # stamp shown in the history command output. 60 | # You can set one of the optional three formats: 61 | # "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" 62 | # or set a custom format using the strftime function format specifications, 63 | # see 'man strftime' for details. 64 | # HIST_STAMPS="mm/dd/yyyy" 65 | 66 | # Would you like to use another custom folder than $ZSH/custom? 67 | # ZSH_CUSTOM=/path/to/new-custom-folder 68 | 69 | # Which plugins would you like to load? 70 | # Standard plugins can be found in ~/.oh-my-zsh/plugins/* 71 | # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ 72 | # Example format: plugins=(rails git textmate ruby lighthouse) 73 | # Add wisely, as too many plugins slow down shell startup. 74 | plugins=( 75 | git extract npm node 76 | ) 77 | 78 | source $ZSH/oh-my-zsh.sh 79 | 80 | # User configuration 81 | 82 | # export MANPATH="/usr/local/man:$MANPATH" 83 | 84 | # You may need to manually set your language environment 85 | # export LANG=en_US.UTF-8 86 | 87 | # Preferred editor for local and remote sessions 88 | # if [[ -n $SSH_CONNECTION ]]; then 89 | # export EDITOR='vim' 90 | # else 91 | # export EDITOR='mvim' 92 | # fi 93 | 94 | # Compilation flags 95 | # export ARCHFLAGS="-arch x86_64" 96 | 97 | # ssh 98 | # export SSH_KEY_PATH="~/.ssh/rsa_id" 99 | 100 | # Set personal aliases, overriding those provided by oh-my-zsh libs, 101 | # plugins, and themes. Aliases can be placed here, though oh-my-zsh 102 | # users are encouraged to define aliases within the ZSH_CUSTOM folder. 103 | # For a full list of active aliases, run `alias`. 104 | # 105 | # Example aliases 106 | # alias zshconfig="mate ~/.zshrc" 107 | # alias ohmyzsh="mate ~/.oh-my-zsh" 108 | -------------------------------------------------------------------------------- /docs/JavaScript:-Objects.md: -------------------------------------------------------------------------------- 1 | ## Getters: 2 | 3 | ```javascript 4 | const employee = { 5 | _name: 'Tom', 6 | _yearOfExp: 20, 7 | _dept: 'CS', 8 | get yearOfExp(){ 9 | 10 | if((typeof this._yearOfExp) === 'number'){ 11 | return `employee current year of experience is ${this._yearOfExp}`; 12 | } else { 13 | return 'Error: cannot retrieve value'; 14 | } 15 | } 16 | }; 17 | 18 | console.log(employee.yearOfExp); 19 | 20 | ``` 21 | 22 | **output:** 23 | ``` 24 | "employee current year of experience is 20" 25 | ``` 26 | 27 | ## Setters: 28 | 29 | ```javascript 30 | const employee = { 31 | _name: 'Ambreen', 32 | _yearOfExp: 20, 33 | _dept: 'CS', 34 | 35 | 36 | set yearOfExp(num){ 37 | if((typeof num) === 'number'){ 38 | this._yearOfExp = num; 39 | return `employee current year of experience is ${this._yearOfExp}`; 40 | } else { 41 | return 'Error: cannot set value'; 42 | } 43 | } 44 | 45 | 46 | }; 47 | 48 | employee.yearOfExp = 25 49 | 50 | console.log(employee._yearOfExp); 51 | 52 | ``` 53 | 54 | **output:** 55 | ``` 56 | 25 57 | ``` 58 | 59 | ## Factory Functions: 60 | 61 | ```javascript 62 | const empFactory = (name, department) => { 63 | return { 64 | name: name, 65 | department: department, 66 | task() { 67 | console.log('Manufacturing'); 68 | } 69 | 70 | } 71 | }; 72 | 73 | const emp1 = empFactory('John', 'Finance'); 74 | 75 | emp1.task(); 76 | 77 | ``` 78 | 79 | **output:** 80 | ``` 81 | "Manufacturing" 82 | ``` 83 | 84 | We can re-write above code by using the destructuring technique that was introduced in ES6 and is also known as property value shorthand: 85 | 86 | ```javascript 87 | const empFactory = (name, department) => { 88 | return { 89 | name, 90 | department, 91 | task() { 92 | console.log('Manufacturing'); 93 | } 94 | 95 | } 96 | }; 97 | 98 | const emp1 = empFactory('John', 'Finance'); 99 | 100 | emp1.task(); 101 | 102 | ``` 103 | 104 | ## Destructured Assignment: 105 | 106 | It allows extracting data from arrays, objects, maps and sets into their own variables. 107 | 108 | ```javascript 109 | const employee = { 110 | first: 'Ambreen', 111 | last: 'Khan', 112 | country: 'Canada', 113 | city: 'Toronto', 114 | twitter: '@ambysan' 115 | }; 116 | 117 | //Getting data in old-fashoined way: 118 | // const first = person.first; 119 | // const last = person.last; 120 | 121 | //This data can be destructured as below; Here curly brackets show new destructuring syntax 122 | const {first, last} = employee; 123 | 124 | console.log(first); // Ambreen 125 | console.log(last); // Khan 126 | ``` 127 | 128 | ## Built-in Object Methods: 129 | 130 | **Object.keys()** 131 | ```javascript 132 | const employee = { 133 | first: 'Ambreen', 134 | last: 'Khan', 135 | country: 'Canada', 136 | city: 'Toronto', 137 | twitter: '@ambysan' 138 | }; 139 | 140 | const employeeKeys = Object.keys(employee); 141 | console.log(employeeKeys); 142 | ``` 143 | 144 | output: 145 | ``` 146 | ["first", "last", "country", "city", "twitter"] 147 | ``` 148 | 149 | **Object.entries()** 150 | ```javascript 151 | const employee = { 152 | first: 'Ambreen', 153 | last: 'Khan', 154 | country: 'Canada', 155 | city: 'Toronto', 156 | twitter: '@ambysan' 157 | }; 158 | 159 | const objEntries = Object.entries(employee); 160 | console.log(objEntries); 161 | 162 | ``` 163 | output: 164 | ``` 165 | [["first", "Ambreen"], ["last", "Khan"], ["country", "Canada"], ["city", "Toronto"], ["twitter", "@ambysan"]] 166 | ``` 167 | 168 | **Object.assign()** 169 | ```javascript 170 | const employee = { 171 | first: 'Ambreen', 172 | last: 'Khan', 173 | country: 'Canada', 174 | city: 'Toronto', 175 | twitter: '@ambysan' 176 | }; 177 | 178 | const techEmployee = Object.assign({skill1: 'JavaScript', skill2: 'Node.JS'}, employee); 179 | 180 | console.log(techEmployee); 181 | ``` 182 | output: 183 | ``` 184 | [object Object] { 185 | city: "Toronto", 186 | country: "Canada", 187 | first: "Ambreen", 188 | last: "Khan", 189 | skill1: "JavaScript", 190 | skill2: "Node.JS", 191 | twitter: "@ambysan" 192 | } 193 | ``` -------------------------------------------------------------------------------- /docs/Node-Package-Manager.md: -------------------------------------------------------------------------------- 1 | ## npm Commands: 2 | 3 | > npm install package-name 4 | 5 | This command will install the package-name & add to the package.json 6 | 7 | > npm uninstall package-name 8 | 9 | This command will remove or uninstall the package-name from node_modules & package.json 10 | 11 | > npm help 12 | 13 | This command is to get a list of all available npm commands. 14 | 15 | > npm ls 16 | 17 | This command will print all top-level installed packages and their dependencies in a tree structure. 18 | 19 | > npm show package-name 20 | 21 | This command will show all the information about the given package-name 22 | 23 | > npm outdated 24 | 25 | This command will show all outdated packages in the current folder. 26 | 27 | > npm update 28 | 29 | This command will update the outdated packages in current folder 30 | 31 | > npm install package-name@latest 32 | 33 | This command will install latest version of given package-name 34 | 35 | ## npm run scripts: 36 | 37 | > npm help npm-scripts 38 | 39 | This command will provide information on how npm handles the "scripts" field 40 | 41 | ## Package.JSON 42 | 43 | Run the command **npm init** to create the file while answering some questions about your project. 44 | 45 | Run the command **npm init -y** to create the file with default values without a need to answer any question. 46 | 47 | This file: 48 | 49 | * Contains meta-data about your project 50 | * Manages dependencies of your project 51 | * Contains scripts that help in generating builds, running tests and some other stuff 52 | 53 | Run the command **npm install** to install dependencies from an existing project using Package.JSON 54 | 55 | **Adding dependencies to Package.JSON** 56 | 57 | > npm install packagename --save //install as devDependency 58 | 59 | Note: As of npm 5.0.0, installed modules are added as a dependency by default, so the --save option is no longer needed. 60 | 61 | > npm install -D packagename //install as dependency 62 | 63 | > npm help install //to check help for npm install command 64 | 65 | **Installing npm packages locally or globally** 66 | 67 | $npm install packagename //installs locally. The command will be available to run from the folder where it is installed. 68 | 69 | $npm install -g packagename //installs globally.The command will be available to run from anywhere. 70 | 71 | npm packages can be installed locally or globally. 72 | 73 | ## Package-lock.JSON 74 | 75 | * Automatically generated for any operations where npm modifies either the node_modules tree, or package.json. 76 | * As the package-lock specifies a version, location and integrity hash for every module and each of its dependencies, the install it creates will be the same, every single time. 77 | 78 | **References:** 79 | 80 | https://medium.com/beginners-guide-to-mobile-web-development/why-package-json-npm-basics-cab3e8cd150 81 | 82 | https://medium.com/coinmonks/everything-you-wanted-to-know-about-package-lock-json-b81911aa8ab8 83 | 84 | ## Semantic Versioning (SemVer) 85 | 86 | Major.Minor.Patch (4.5.0) 87 | 88 | * Major: Breaking Changes 89 | * Minor: Backward Compatible 90 | * Patch: Bug Fixes 91 | 92 | **Symbols used in SemVer:** 93 | 94 | ~ means update can install the most recent patch version (e.g. ~4.5.0) - matches any 4.5.x version. 95 | 96 | ^ means update can install most recent minor version (e.g. ^4.5.0) - matches any 4.x.y version. 97 | 98 | ## Common Issues: 99 | 100 | **Issue:** 101 | 102 | Error: Cannot find module '../lib/utils/unsupported.js' 103 | 104 | **Solution:** 105 | 106 | Uninstall node: $brew uninstall --force node 107 | 108 | Install it again: $brew install node 109 | 110 | If the above solution doesn't work, check out: https://gist.github.com/DanHerbert/9520689 111 | 112 | OR run $brew uninstall --force node 113 | 114 | then visit https://nodejs.org/en/ and download the LTS version and install and the error will be gone. 115 | 116 | **Issue:** 117 | 118 | npm throws error while trying to install any package globally without using sudo 119 | 120 | **Solution:** 121 | 122 | Check out: 123 | 124 | https://www.competa.com/blog/how-to-run-npm-without-sudo/ 125 | 126 | https://www.competa.com/blog/use-nvm-for-fun-and-profit-and-to-run-npm-without-sudo/ -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | **Git & Github** 2 | * [Git How to's](https://github.com/arkhangelsk/STT-Notes/wiki/Git-How-to's) 3 | * [Git commonly used commands](https://github.com/arkhangelsk/STT-Notes/wiki/Git-Common-Commands) 4 | 5 | *** 6 | 7 | **JavaScript** 8 | * [JavaScript: Quick Reference](https://github.com/arkhangelsk/Learning-Grid/wiki/JavaScript-Quick-Reference) 9 | * [JavaScript: ES6 Functions](https://medium.freecodecamp.org/es6-functions-9f61c72b1e86) 10 | * [JavaScript: Iteration Methods](https://github.com/arkhangelsk/Learning-Grid/wiki/JavaScript:-Iteration-Methods) 11 | * [JavaScript: Objects](https://github.com/arkhangelsk/Learning-Grid/wiki/JavaScript:-Objects) 12 | * [JavaScript: Classes](https://github.com/arkhangelsk/Learning-Grid/wiki/JavaScript:-Classes) 13 | * [JavaScript: Fetch API](https://github.com/arkhangelsk/Learning-Grid/wiki/JavaScript:-Fetch-API) 14 | * [JavaScript: Modules](https://github.com/arkhangelsk/Learning-Grid/wiki/JavaScript:-Modules) 15 | * [Browser Compatibility Issues from new ES6 Syntax](https://github.com/arkhangelsk/Learning-Grid/wiki/Browser-Compatibility-Issues-from-new-ES6-Syntax) 16 | * [How to Convert ES6 into ES5 using Babel](https://github.com/arkhangelsk/Learning-Grid/wiki/How-to-Convert-ES6-into-ES5-using-Babel) 17 | 18 | *** 19 | 20 | * [JavaScript: How to's](https://github.com/arkhangelsk/Learning-Grid/wiki/JavaScript:-How-to's) 21 | * [JavaScript: Tools](https://github.com/arkhangelsk/Learning-Grid/wiki/JavaScript:-Tools) 22 | * [JavaScript: Utility Libraries](https://github.com/arkhangelsk/Learning-Grid/wiki/JavaScript:-Utility-Libraries) 23 | * [JavaScript: Learning Resources](https://github.com/arkhangelsk/Learning-Grid/wiki/JavaScript:-Learning-Resources) 24 | 25 | 26 | *** 27 | 28 | **Node.js** 29 | * [Node.js Setup](https://github.com/arkhangelsk/STT-Notes/wiki/Node.js-Setup) 30 | * [Node Package Manager](https://github.com/arkhangelsk/STT-Notes/wiki/Node-Package-Manager) 31 | * [Node: Common Commands](https://github.com/arkhangelsk/STT-Notes/wiki/Node:-Common-Commands) 32 | * [Node Modules](https://github.com/arkhangelsk/STT-Notes/wiki/Node-Modules) 33 | * [Debugging Node Applications](https://github.com/arkhangelsk/STT-Notes/wiki/Debugging-Node-Application) 34 | * [Making an HTTP Request in NodeJS](https://github.com/arkhangelsk/STT-Notes/wiki/Making-an-HTTP-Request-or-REST-API-call-in-Node-JS) 35 | 36 | *** 37 | 38 | **REST API** 39 | * [Free Public RESTful JSON APIs](https://github.com/arkhangelsk/STT-Notes/wiki/Free-Public-RESTful-JSON-APIs) 40 | * [Making an HTTP Request or REST API call in NodeJS](https://github.com/arkhangelsk/Learning-Grid/wiki/Making-an-HTTP-Request-or-REST-API-call-in-Node-JS) 41 | 42 | *** 43 | 44 | **VS Code** 45 | * [Free Course: VS Code Beginner by Alan Simpson](http://alansimpson.thinkific.com/courses/beginner-vs-code) 46 | * [Free Course: Beginners Debugging JavaScript with VS Code and Chrome by Alan Simpson](http://alansimpson.thinkific.com/courses/beginners-debugging-javascript-with-vs-code-and-chrome) 47 | * [Free Course: Easy Markdown with VS Code by Alan Simpson](http://alansimpson.thinkific.com/courses/easy-markdown-with-vs-code) 48 | * [Other Short Tutorials about VS Code by Alan Simpson](https://alansimpson.me/vscode/index.html) 49 | * [10 Must-have VS Code Extensions for JavaScript Developers](https://www.sitepoint.com/vs-code-extensions-javascript-developers/) 50 | * [VS Code can do that! Brought to you by Burke Holland and Sarah Drasner](https://vscodecandothat.com/) 51 | * [Configure TypeScript, TSLint, and Prettier in VS Code for React Native Development](https://medium.com/@sgroff04/configure-typescript-tslint-and-prettier-in-vs-code-for-react-native-development-7f31f0068d2) 52 | * [Keep Code Consistent Across Developers The Easy Way — With Prettier & ESLint](https://itnext.io/keep-code-consistent-across-developers-the-easy-way-with-prettier-eslint-60bb7e91b76c) 53 | 54 | *** 55 | 56 | **Test Automation** 57 | * [Tools & Frameworks](https://github.com/arkhangelsk/Learning-Grid/wiki/Tools-&-Frameworks) 58 | * [Learning Resources](https://github.com/arkhangelsk/Learning-Grid/wiki/Test-Automation:-Learning-Resources) 59 | 60 | *** 61 | 62 | **JavaScript Testing** 63 | * [An overview of javascript testing in 2018](https://medium.com/welldone-software/an-overview-of-javascript-testing-in-2018-f68950900bc3) 64 | 65 | *** 66 | 67 | **Mac O/S** 68 | * [Setting up your MAC Machine](https://github.com/arkhangelsk/Learning-Grid/wiki/Setting-up-you-mac-machine) 69 | * [Mac: Tips & Tricks](https://github.com/arkhangelsk/Learning-Grid/wiki/Tips-&-Tricks) 70 | * [Unix and Linux commands help](https://www.computerhope.com/unix.htm) 71 | * [Common CLI commands](https://github.com/arkhangelsk/STT-Notes/wiki/Common-CLI-Commands) 72 | * [Working with Z Shell (zsh)](https://github.com/arkhangelsk/STT-Notes/wiki/Working-with-Z-Shell-(zsh)) 73 | 74 | 75 | *** 76 | 77 | **Miscellaneous** 78 | * [cURL](https://github.com/arkhangelsk/Learning-Grid/wiki/cURL) 79 | * [Docker: Frequently Used Commands](https://github.com/arkhangelsk/Learning-Grid/wiki/Docker:-Frequently-Used-Commands) 80 | * [Docker: The Basics](https://github.com/arkhangelsk/Learning-Grid/wiki/Docker-:-The-Basics) 81 | * [Working with Environment Variables in Node.JS](https://github.com/arkhangelsk/Learning-Grid/wiki/Working-with-Environment-Variables-in-Node.JS) 82 | * [Creating Documentation](https://github.com/arkhangelsk/Learning-Grid/wiki/Creating-Documentation) 83 | * [Data Science Beginner](https://alansimpson.me/datascience/beginner/) 84 | 85 | 86 | *** 87 | 88 | **Resources** 89 | * [Learning Resources That Rocks](https://github.com/arkhangelsk/Learning-Grid/wiki/Learning-Resources-That-Rocks!) -------------------------------------------------------------------------------- /docs/JavaScript:-Iteration-Methods.md: -------------------------------------------------------------------------------- 1 | Built-in JavaScript methods that help to iterate through an array are called iteration methods or iterators. Let's have a look at the different type of iterators: 2 | 3 | 1. forEach 4 | 2. map 5 | 3. filter 6 | 4. find 7 | 5. findIndex 8 | 6. every 9 | 7. some 10 | 8. reduce 11 | 9. for...in 12 | 13 | ## 1. The .forEach() method: 14 | * .forEach() takes an argument of callback function. 15 | * .forEach() will loop through the array and execute the callback function for each element of the array. 16 | * During each iteration, the current element will be passed as an argument to the callback function. 17 | * The callback function can be in function declaration format, function expression or an arrow function. 18 | * The return value for .forEach() will be undefined. 19 | 20 | ```javascript 21 | const boxes = [ 22 | { height: 10, width: 30 }, 23 | { height: 20, width: 50 }, 24 | { height: 30, width: 60 } 25 | ]; 26 | let areas = []; 27 | 28 | boxes.forEach(function(box){ 29 | areas.push(box.height*box.width); 30 | }); 31 | 32 | console.log(areas); 33 | ``` 34 | **output:** 35 | ``` 36 | [ 300, 1000, 1800 ] 37 | ``` 38 | 39 | ## 2. The .map() method: 40 | * when we call .map() on an array, it takes an argument of a callback function and returns a new array. 41 | 42 | ```javascript 43 | let students = [{id: 1, name: 'Tim', course: 'Java'}, 44 | {id: 2, name: 'James', course: 'JavaScript'}, 45 | {id: 3, name: 'David', course: 'Python'}]; 46 | 47 | //directly getting a property value from array using map 48 | let name = students.map(function(student){ 49 | return student['name']; 50 | }); 51 | 52 | function pluck(array, property){ 53 | let a2 = array.map(function(obj){ 54 | return obj[property]; 55 | }); 56 | return a2; 57 | } 58 | 59 | console.log(name); 60 | 61 | //getting desired peroperty values using a function 62 | console.log(pluck(students, 'id')); 63 | console.log(pluck(students, 'name')); 64 | console.log(pluck(students, 'course')); 65 | 66 | ``` 67 | **output:** 68 | ``` 69 | [ 'Tim', 'James', 'David' ] 70 | [ 1, 2, 3 ] 71 | [ 'Tim', 'James', 'David' ] 72 | [ 'Java', 'JavaScript', 'Python' ] 73 | ``` 74 | 75 | ## 3. The .filter() method: 76 | * The .filter() method returns a new array after filtering out certain elements from the original array. 77 | * The callback function for the .filter() method returns either true or false depending on the element that is passed to it. 78 | * The elements for which the callback function returns true as value is added to the new array. 79 | 80 | ```javascript 81 | let employees = [{id: 1, name: 'James', dept: 'IT'}, 82 | {id: 2, name: 'David', dept: 'Accounts'}, 83 | {id: 3, name: 'Tim', dept: 'HR'}, 84 | {id: 4, name: 'Vinod', dept: 'IT'}]; 85 | 86 | const deptCS_Filter = employees.filter(function(employee){ 87 | return employee.dept === 'IT'; 88 | }); 89 | 90 | console.log(deptCS_Filter); 91 | ``` 92 | **output:** 93 | ``` 94 | [ { id: 1, name: 'James', dept: 'IT' }, 95 | { id: 4, name: 'Vinod', dept: 'IT' } ] 96 | ``` 97 | 98 | ## 4. The .find() method: 99 | * find() method executes a callback function once for each element in the array until it finds a value that returns as true. 100 | * find() only returns the **first element** matching the given search criteria. 101 | * If nothing is found matching the given search criteria, undefined is returned. 102 | * find() does not mutate or change the original Array. 103 | 104 | ```javascript 105 | let employees = [{id: 1, age: 35, name: 'James', dept: 'IT', education: 'Masters'}, 106 | {id: 2, age: 25, name: 'David', dept: 'Accounts', education: 'High School'}, 107 | {id: 3, age: 45,name: 'Tim', dept: 'HR', education: 'Graduate'}, 108 | {id: 4, age: 50,name: 'Vinod', dept: 'IT', education: 'PHD'}]; 109 | 110 | 111 | function chooseEmployee(arrEmployee){ 112 | 113 | return arrEmployee.find(function(emp){ 114 | return emp.name === 'David'; 115 | }); 116 | 117 | } 118 | 119 | console.log(chooseEmployee(employees)); 120 | ``` 121 | **output:** 122 | 123 | ``` 124 | { id: 2, age: 25, name: 'David', dept: 'Accounts', education: 'High School' } 125 | ``` 126 | 127 | ## 5. The .findIndex() method: 128 | * findIndex() returns the **index** of the first element in the array that satisfies the given search criteria. 129 | * If nothing is found matching the given search criteria, -1 is returned. 130 | 131 | ```javascript 132 | let employees = [{id: 1, age: 35, name: 'James', dept: 'IT', education: 'Masters'}, 133 | {id: 2, age: 25, name: 'David', dept: 'Accounts', education: 'High School'}, 134 | {id: 3, age: 45,name: 'Tim', dept: 'HR', education: 'Graduate'}, 135 | {id: 4, age: 50,name: 'Vinod', dept: 'IT', education: 'PHD'}]; 136 | 137 | 138 | function chooseEmployee(arrEmployee){ 139 | 140 | return arrEmployee.findIndex(function(emp){ 141 | return emp.name === 'Tim'; 142 | }); 143 | 144 | } 145 | 146 | console.log(chooseEmployee(employees)); 147 | ``` 148 | 149 | output: 150 | ``` 151 | 2 152 | ``` 153 | 154 | ## 6. The .every() method: 155 | 156 | ```javascript 157 | var students = [ 158 | { id: 1, passed: true }, 159 | { id: 2, passed: false}, 160 | { id: 3, passed: true } 161 | ]; 162 | 163 | const hasPassed; 164 | 165 | hasPassed = students.every(function(student){ 166 | return student.passed === true; 167 | }); 168 | 169 | console.log(hasPassed); 170 | ``` 171 | 172 | output: 173 | ``` 174 | false 175 | ``` 176 | 177 | ## 7. The .some() method: 178 | 179 | ```javascript 180 | let students = [ 181 | { id: 1, passed: true }, 182 | { id: 2, passed: false}, 183 | { id: 3, passed: true } 184 | ]; 185 | 186 | let hasFailed; 187 | 188 | hasFailed = students.some(function(student){ 189 | return student.passed === false; 190 | }); 191 | 192 | console.log(hasFailed); 193 | ``` 194 | **output:** 195 | ``` 196 | true 197 | ``` 198 | 199 | ## 8. The .reduce() method: 200 | 201 | * The .reduce() method returns a single value after iterating through the elements of an array 202 | * The .reduce() method takes a callback function as first argument. This callback function has two parameters. 203 | * The .reduce() method can also take an optional second parameter to set an initial value for the first argument in the callback function. 204 | 205 | ```javascript 206 | let passed = [{ year: 2016 ,pass: 64 }, { year: 2017 , pass: 42 } , { year: 2018 ,pass: 52 }]; 207 | const totalPassed; 208 | 209 | totalPassed = passed.reduce(function(total, student){ 210 | return student.pass + total; 211 | },0); 212 | 213 | console.log(totalPassed); 214 | ``` 215 | 216 | **output:** 217 | ``` 218 | 158 219 | ``` 220 | 221 | ## 9. for...in 222 | * for...in will execute a given block of code for each property in an object. 223 | 224 | ```javascript 225 | let dept = 226 | { 227 | finance: { 228 | 'employee1': {id: 1, age: 35, name: 'James', dept: 'IT', education: 'Masters'}, 229 | 'employee2': {id: 2, age: 25, name: 'David', dept: 'Accounts', education: 'High School'}, 230 | 'employee3': {id: 3, age: 45,name: 'Tim', dept: 'HR', education: 'Graduate'}, 231 | 'employee4': {id: 4, age: 50,name: 'Vinod', dept: 'IT', education: 'PHD'} 232 | } 233 | }; 234 | 235 | 236 | for (let employee in dept.finance) { 237 | console.log( employee + ': ' + dept.finance[employee].name); 238 | }; 239 | ``` 240 | 241 | **output:** 242 | ``` 243 | "employee1: James" 244 | "employee2: David" 245 | "employee3: Tim" 246 | "employee4: Vinod" 247 | ``` -------------------------------------------------------------------------------- /docs/JavaScript-Quick-Reference.md: -------------------------------------------------------------------------------- 1 | ## Data Types in JavaScript 2 | 3 | * There are seven fundamental data types in JavaScript: 4 | 5 | Number, String, Boolean, Null, Undefined, Symbol, Object 6 | 7 | * The typeof keyword returns the data type of a value. 8 | 9 | ```javascript 10 | const num = 100; 11 | console.log(typeof num); //output: number 12 | ``` 13 | 14 | ## var, let & const 15 | 16 | **var:** 17 | 18 | * The var keyword is used in pre-ES6 versions of JS. 19 | 20 | ```javascript 21 | var status = 'Passed'; 22 | ``` 23 | 24 | **let:** 25 | 26 | ```javascript 27 | let status = 'Passed'; 28 | let empNumber; 29 | ``` 30 | 31 | * If no value is assigned to a variable that is declared using the let keyword, it will automatically have a value of undefined. 32 | 33 | **const:** 34 | 35 | ```javascript 36 | const color = 'Blue'; 37 | ``` 38 | 39 | * Constant variables must be assigned a value at the time of declaration. If we declare a const variable without a value, it will result in SyntaxError. 40 | * A const variable cannot be reassigned as it is constant. If we try to reassign a const variable, it will result in a TypeError. 41 | 42 | ## Template Strings/Template Literals: 43 | 44 | * JavaScript Template literals are the Literals or Strings allowing Expression in between them. 45 | * The delimiter of a template literal is the backtick ``` character 46 | * An expression inside the literal is enclosed in curly braces {} with a preceding dollar sign $ 47 | 48 | ```javascript 49 | function getDate(){ 50 | const year = new Date().getFullYear(); 51 | //return "The year is: " + year; //This is ES5 format 52 | 53 | //Using ES6 format: 54 | return `This year is: ${year}`; 55 | } 56 | 57 | console.log(getDate()); 58 | ``` 59 | 60 | ## Thruthy & Falsy Values 61 | 62 | * **Truthy:** Any value that is non-falsy is a truthy value 63 | * **Falsy:** Falsy values includes: 0, Empty strings like " " or ' ', null (means there is no value at all), undefined (means no value assigned to a declared variable), NaN (Not a Number) 64 | 65 | ## Short-circuit evaluation 66 | 67 | ```javascript 68 | let signInName = username || 'Guest'; 69 | ``` 70 | In above example || statements check the left-hand condition first, so the variable signInName will be assigned the value of username if is truthy (or available), and it will be assigned the value of 'Guest' if the username is falsy. This concept is known as short-circuit evaluation. 71 | 72 | ## Ternary Operator: 73 | 74 | ```javascript 75 | let isPass = true; 76 | 77 | isPass? console.log('You Passed the exam!') : console.log('oh, you failed. Try Again!'); 78 | ``` 79 | 80 | ## Function Declarations: 81 | 82 | ```javascript 83 | function getStatus(){ 84 | console.log('Passed!'); 85 | } 86 | 87 | getStatus(); //output: Passed! 88 | ``` 89 | 90 | ```javascript 91 | function getStatus(name){ 92 | console.log(name + ', You have Passed!'); 93 | } 94 | 95 | getStatus('Ambreen'); //output: Ambreen, You have Passed! 96 | ``` 97 | 98 | ## Default Parameters in ES6: 99 | 100 | ```javascript 101 | function greeting (name = 'Guest') { 102 | console.log(`Hi ${name}!, Welcome to Software Testing Trends.`) 103 | } 104 | 105 | greeting('Ambreen') // Output: Hi Ambreen!, Welcome to Software Testing Trends.! 106 | greeting() // Output: Hi Guest!, Welcome to Software Testing Trends. 107 | ``` 108 | 109 | NOTE: 110 | * When a value of undefined is passed as the value, it is considered invalid and the default value is assigned to the parameter. 111 | * If null is passed as the value, it is considered valid and null is assigned to the parameter. 112 | 113 | **Learn more:** https://www.sitepoint.com/es6-default-parameters/ 114 | 115 | ## Function Expressions: 116 | 117 | ```javascript 118 | const exerciseDay = function(day){ 119 | if (day === 'Wednesday'){ 120 | return 'Get Ready for exercise class...'; 121 | } else { 122 | return 'Enjoy, just relax...'; 123 | } 124 | } 125 | 126 | console.log(exerciseDay('Tuesday')); 127 | ``` 128 | 129 | ## Arrow Functions: 130 | * Arrow functions provide a concise syntax for writing function expressions. 131 | * They utilize a new token, =>, that looks like a fat arrow. 132 | * Arrow functions are anonymous and simplify function scoping 133 | * Arrow functions change the way this binds in functions 134 | * The parenthesis for an argument can be removed if there is a single argument. 135 | * Curly brackets aren’t required if there is only one expression present in the function body. 136 | * If there is no argument, still we need to have empty parenthesis. 137 | 138 | ```javascript 139 | //ES5 Function Syntax 140 | const sum1 = function(a, b){ 141 | return a + b; 142 | } 143 | 144 | //ES6 Arrow Function Syntax 145 | const sum2 = (a, b) => a + b; //Implicit Return 146 | 147 | console.log((sum1(2,5))); 148 | console.log((sum2(3,6))); 149 | ``` 150 | 151 | ```javascript 152 | //An arrow function with single argument and single exression in function body 153 | const num1 = number => number * 2; 154 | 155 | //If there is no argument, still we need to have empty parenthesis 156 | const num2 = () => 2+2; 157 | ``` 158 | 159 | ## Functions are first-class objects 160 | 161 | * Functions can be assigned to variables and then reassigned to new variables. 162 | * JavaScript functions can have properties such as .length and .name and methods like .toString() 163 | * Functions can be passed as parameters. 164 | 165 | ```javascript 166 | const determineGeoLocationOfTheStore = () => { 167 | console.log('Inside Geolocation Method...') 168 | } 169 | 170 | // Write your code below 171 | const geoLoc = determineGeoLocationOfTheStore; 172 | 173 | geoLoc(); 174 | 175 | console.log(geoLoc.name); 176 | 177 | //output: 178 | 179 | //"Inside Geolocation Method..." 180 | //"determineGeoLocationOfTheStore" 181 | ``` 182 | 183 | ## High-order Function: 184 | 185 | * A function that either accepts functions as parameters, returns a function, or can do both are called high-order functions. 186 | * When a function is passed as an argument to another function, then function name is mentioned without the parentheses. (as we dont want to call the function at this stage) 187 | * Function parameters can also be anonymous functions. 188 | 189 | ## Call-back Functions: 190 | 191 | * Functions that are passed in as parameters and then invoked are called callback functions as they get called during the execution of the higher-order function. 192 | 193 | ## Working with Arrays: 194 | 195 | * Elements in an array declared with const remain mutable (i.e. the contents of a const array can be changed, but we cannot reassign a new array or a different value to a const array.) 196 | * Use array **.length** property to determine the number of elements in an array. 197 | ```javascript 198 | const tasks = ['Task 1', 'Task 2', 'Task 3']; 199 | tasks.length //output: 3 200 | ``` 201 | * Use **.push()** method to add items to the end of an array. It can take a single argument or multiple arguments that are separated by commas. 202 | * .push() is also referred to as a destructive array method since it mutates(changes) the initial array. 203 | 204 | ```javascript 205 | const tasks = ['Task 1', 'Task 2', 'Task 3']; 206 | tasks.push('Task 4', 'Task 5'); 207 | ``` 208 | * Use **.pop()** method to remove the last item of an array. This method returns the value of the last element. 209 | * This method also mutates the original array. 210 | 211 | ```javascript 212 | const tasks = ['Task 1', 'Task 2', 'Task 3']; 213 | const last = tasks.pop(); 214 | ``` 215 | 216 | * Use **shift()** method to remove the first element from an array. This method returns the removed element. 217 | 218 | ```javascript 219 | const tasks = ['Task 1', 'Task 2', 'Task 3']; 220 | const first = tasks.shift(); 221 | ``` 222 | 223 | * Use **unshift()** method to add one or more elements to the beginning of an array. This method returns the new length of the array. 224 | 225 | ```javascript 226 | const tasks = ['Task 1', 'Task 2', 'Task 3']; 227 | const total = tasks.unshift('Task 0'); 228 | console.log(total); //output: 4 229 | ``` 230 | 231 | * Use **slice()** method to get a portion of an array into a new array object selected from beginning to end (end not included). 232 | * Note that .slice() is non-mutating. It does not change elements from the original array. 233 | 234 | ```javascript 235 | const tasks = ['Task 1', 'Task 2', 'Task 3', 'Task 4']; 236 | const total = tasks.slice(1,3); 237 | console.log(total); //output: ["Task 2", "Task 3"] 238 | ``` 239 | 240 | * Use **indexOf()** method to get the first index at which a given element can be found in the array. It will return -1 if the element is not present. 241 | 242 | ```javascript 243 | const tasks = ['Task 1', 'Task 2', 'Task 3', 'Task 4']; 244 | const index = tasks.indexOf('Task 3'); 245 | console.log(index); //output: 2 246 | ``` 247 | 248 | ## Additional Notes: 249 | 250 | https://softwaretestingtrends.com/es6-quick-reference/ 251 | 252 | 253 | --------------------------------------------------------------------------------