Skip to content

Instantly share code, notes, and snippets.

Chase Isley theonlychase

Block or report user

Report or block theonlychase

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View git-process-VH
## VH Git Process
1. Get Status
1. `git status`
2. Check what branch you're on
1. `git branch`
3. Add all files
1. `git add .`
4. Create Branch with with ticket name and small description
1. `git checkout -b VHMN-3965-helpful-cunsumer-review-button`
View vue-test-utils
`describe()` - describe generally outlines what the test is about
`it()` - it represents a single piece of responsibility that the subject of the test should fulfill.
1. Two ways to render
1. `mount()`
2. `shallowMount()`
3. A component mounted returns a `wrapper` which is an object containing the Vue Component
4.
View map-weakmap
## Map
1. Map is a collection of keyed data items, just like an `Object`. But the main difference is that `Map` allows keys of any type.
2. Maps Main Methods
1. `new Map()` - creates the map
2. `map.set(key, value)` - stores value by key
3. `map.get(key)` – returns the value by the key, undefined if key doesn’t exist in map.
4. `map.has(key)` – returns true if the key exists, false otherwise.
5. `map.delete(key)` – removes the value by the key.
View tips-tricks
## Type Conversion - Number and String
1. The `+` operator when used as a unary operator always converts its operand to a `number`.
2. 2. Using the unary `+` operator on a value is functionally equivalent to casting the value using the `Number()` function.
1. `+new Date === Number(new Date); // true`
```javascript
console.log(+'100'); // 100
console.log(+null); // 0
console.log(+void 0); // NaN
View js-types
## Types Basics
1. Does JS have types?
1. Dynamically typed
1. infer variable types at runtime
2. Once your code is run the compiler/interpreter will see your variable and its value then decide what type it is
2. Weakly typed
1. Allow types to be inferred as another type (coersion)
View instanceof-typeof
## typeof
Unary operator that returns a string indicating the type of the unevaluated operand.
```javascript
const a = "I'm a string primitive";
const b = new String("I'm a String Object");
typeof a; --> returns 'string'
typeof b; --> returns 'object'
View sort
// Sort words by a given String
const sortByString = (arr, str) => arr.sort(([a], [b]) => str.indexOf(a) - str.indexOf(b)); // I guess the [a] [b] gives you the first letter of the value
sortByString(["apple", "banana", "cherry", "date"], "dbca") // "date", "banana", "cherry", "apple"]
View create-array
// Arrays are objects with numerical keys and a length property
// FANCY OBJECTS
const arr = []
typeof arr // "object"
const friendsArray = ['Jake', 'Jordyn', 'Mikenzi']
const friendsObj = {0: 'Jake', 1: 'Jordyn', 2: 'Mikenzi'}
friendsArray[1] // Jordyn
friendsObj[1] // Jordyn
View class
// Create Parent Class
class Person {
constructor(first, age) {
this.first = first;
this.age = age;
}
fullName() {
console.log(`${this.first} is ${this.age} years old`)
}
View proto-__proto__
## prototype vs __proto__
1. Two prototypes in Javascript
1. `prototype`
1. Special property assigned to any function you make in JS
2. This `prototype` is the same object that is pointed to by the [[Prototype]] of the newly created object from that function (using `new` keyword)
2. `[[Prototype]]`
1. This property is a reference to the `prototype` of the function from which the object was made
You can’t perform that action at this time.