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
const obj = {
dev: 'bfe',
a: function() {
return this.dev
},
b() {
return this.dev
},
c: () => {
return this.dev
@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];
https://stackoverflow.com/questions/37601282/javascript-array-splice-vs-slice/54114834#54114834
useEffect(() => {
/**
* trapping next router before-pop-state to manipulate router change
* on browser back button quick filter modal should be closed
*/
router.beforePopState(() => {
if (isOpen) {
/**
* only applicable if modal is open.
*/
@sachinKumarGautam
sachinKumarGautam / common-polyfills.js
Last active February 24, 2023 09:02
This doc includes polyfills for the most common JS functions
// debounce
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
@sachinKumarGautam
sachinKumarGautam / dom-proprties.js
Created June 18, 2020 02:19
This document includes most of the common properties we use in dom
// EXAMINE THE DOCUMENT OBJECT //
// console.dir(document);
// console.log(document.domain);
// console.log(document.URL);
// console.log(document.title);
// //document.title = 123;
// console.log(document.doctype);
// console.log(document.head);
// console.log(document.body);
@sachinKumarGautam
sachinKumarGautam / js wait function
Created December 12, 2018 15:28
js wait function
function waitForever() {
return new Promise(r => {});
}
// Usage:
await waitForever();
const express = require('express')
const next = require('next')
const cookieParser = require('cookie-parser')
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
const url = require('url')
const path = require('path')
const expressApp = express()
@sachinKumarGautam
sachinKumarGautam / event-litsener-for-list.js
Created October 8, 2018 06:18
Optimized event litsensers for list for litseners
class SomeComponent extends React.PureComponent {
// Each instance of SomeComponent has a cache of click handlers
// that are unique to it.
clickHandlers = {};
// Generate and/or return a click handler,
// given a unique identifier.
getClickHandler(key) {
@sachinKumarGautam
sachinKumarGautam / fade-in-text.css
Created August 26, 2018 08:23
This gist is for fade in animation of text when page loads
div {
opacity: 0;
animation: fadeIn 1s 0.5s forwards
}
@keyframes fadeIn {
100% {
opcaity: 1
}
}