Skip to content

Instantly share code, notes, and snippets.

View sachinKumarGautam's full-sized avatar
🍷
Frontend Engineer, Love ReactJs

Sachin Kumar sachinKumarGautam

🍷
Frontend Engineer, Love ReactJs
View GitHub Profile
@sachinKumarGautam
sachinKumarGautam / iterators.js
Last active December 28, 2021 08:06 — forked from aegorenkov/iterators.js
HardParts Promises and Iterators
// Type JavaScript here and click "Run Code" or press Ctrl + s
console.log('Hello, world!');
// CHALLENGE 1
function sumFunc(arr) {
// YOUR CODE HERE
let accumulator = 0;
for (let i = 0; i < arr.length; i++) {
accumulator += arr[i];
@sachinKumarGautam
sachinKumarGautam / service-workers.md
Created May 17, 2018 14:43 — forked from lusan/service-workers.md
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

/** Polymorphism is one of the tenets of Object Oriented Programming (OOP). It is the practice of designing objects to share behaviors and to be able to override shared behaviors with specific ones. Polymorphism takes advantage of inheritance in order to make this happen.
In OOP everything is considered to be modeled as an object. This abstraction can be taken all the way down to nuts and bolts for a car, or as broad as simply a car type with a year, make, and model.
To have a polymorphic car scenario there would be the base car type, and then there would subclasses which would inherit from car and provide their own behaviors on top of the basic behaviors a car would have. For example, a subclass could be TowTruck which would still have a year make and model, but might also have some extra behaviors and properties which could be as basic as a flag for IsTowing to as complicated as the specifics of the lift.
Getting back to the example of people and employees, all employees are people, but all people are n
function Animal(name) {
this.name = name;
}
// Example method on the Animal object
Animal.prototype.getName = function() {
return this.name;
}
function Mammal(name, hasHair) {