Skip to content

Instantly share code, notes, and snippets.

View justcoder1's full-sized avatar

Justin Heath justcoder1

View GitHub Profile
@justcoder1
justcoder1 / Functions.js
Created July 29, 2021 09:57
JavaScript - Functions
// Original Functions
(hello = function() {
return "Hello World!"
}()) // By putting the () at the end this invokes the function
// Arrow Function
hello = () => {
return "Hello World!"
}
@justcoder1
justcoder1 / MongoDB_Aggregate.txt
Last active July 30, 2021 15:33
MongoDB_Aggregation
// Match Function
db.articles.aggregate([ { $match : { author : "dave" } } ]);
@justcoder1
justcoder1 / GIT.txt
Created July 31, 2021 10:13
GITHub and GIT commands
**Creating a New Project**
1. Create a folder on your computer and start your work in VSc
2. Create a Repo on GITHub.
3. Then put these into GIT:
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/URL.git
@justcoder1
justcoder1 / TS-Types
Created August 9, 2021 13:56
TS-Types
# Type Basics
### Type declaration
There are several ways we can declare type in TS
ts
let word: string = "test";
let num: number = 101;
let words: string[] = ["this", "is", "an", "array", "of", "strings"];
@justcoder1
justcoder1 / TS-Testing
Created August 9, 2021 13:58
TS-Testing
## Testing with TypeScript
<br/>
Yes, TypeScript(TS) allows us to be strict with the `types` of data we call functions with and the types we allow to be returned - how that data should look. However, TS doesn't have any impact on our logic, or prevent a function returning data with an incorrect value.
Therefore, the need for testing remains and TS can work with TDD to allow for cleaner tests that only test the behaviour of our code, with TS handling any edge cases.
TS compiles down to JavaScript(JS), meaning there are many Node.js compatible testing frameworks available with great documentation. These include [Mocha](https://mochajs.org/Mocha) (testing framework) and [Chai](https://www.chaijs.com/) (assertion library) or [Jest](https://jestjs.io/) (framework _and_ library). Most frameworks behave in a similar way so the the choice is yours.