Skip to content

Instantly share code, notes, and snippets.

View Ghanshyam-K-Dobariya's full-sized avatar
🎯
Focusing

Shyam Ghanshyam-K-Dobariya

🎯
Focusing
View GitHub Profile
@Ghanshyam-K-Dobariya
Ghanshyam-K-Dobariya / gist:cd0bfd99b44c5e0eeef09b383f9d148f
Last active March 22, 2022 04:33
general_questions_for_new_champs.txt
1 - When your studies will be complited?
2 - Are you looking for internship or full time job?
3 - your job location preferences (top 3 to 4 cities only)
4 - area of interests
5 - portfolio url - (or resume url)
-------------
In your resume -> Please include 4 to 5 projects you have done (during college time + as side projects) along with link of code & demo.
@Ghanshyam-K-Dobariya
Ghanshyam-K-Dobariya / prototype_question_1.js
Last active February 24, 2022 05:56
prototype_question_1.js
const nameObj = {
child: "c",
parents: "p",
grandParents: "gP",
};
/* Code 1
class GrandParent {
constructor({ grandParents }) {
this.grandParents = grandParents;

Create a Wallet function that can be called multiple times & maintain balance and transactions, we should be able to call it in a chain way. example is 👇

Wallet(); // prints nothing or its up to you whatever you want to print.
Wallet().getBalance(); // Balance is 0.

Wallet().add(50).add(70).getBalance(); // Added 50. Added 70. Balance is 120.
Wallet().showTransactions(); // +50 <<Date time>>. +70 <<Date time>>.
/*
what will be the o/p of this code ?
this was asked by one tech lead from fk.
*/
var testObj = {
bankId: 13,
accounts: [
{ accountName: "abc", currentBalance: { cash: 10 }, subAccounts: [] },
{
accountName: "bcd",
@Ghanshyam-K-Dobariya
Ghanshyam-K-Dobariya / gist:3f8c53965402a63e2a6594080b5b8cde
Created December 4, 2020 05:19
Find job execution order when one job is dependent on another job(s)
const inputX = {
1: [2],
2: [3],
3: [4],
4: [6, 1],
};
const inputY = {
1: [2, 3],
2: [4, 5],
};
@Ghanshyam-K-Dobariya
Ghanshyam-K-Dobariya / This_In_React_Component.md
Last active August 20, 2019 11:58
Value of this inside react component method

In a JavaScript method, the value of this has nothing to do with the class on which it was defined. Instead, it depends on the object that it was called upon.

import React from "react";
import ReactDOM from "react-dom";

class App extends React.Component {
  render() {
 var { handleClick } = this;
@Ghanshyam-K-Dobariya
Ghanshyam-K-Dobariya / FormValidation.html
Created August 20, 2019 11:26
Basic form validation using vanila js
<html>
<head>
<title>Parcel Sandbox</title>
<meta charset="UTF-8" />
<script>
function isValidEmailId(emailId) {
var exp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
return exp.test(emailId)
}

Ever wondered why setting array.length = 0 makes an array empty or array.length = 'some string' throws exception ? Code example.

screen shot 2018-09-14 at 10 16 50 
am

So now you have curiosity to know what happens in the background when command array.length = 0 takes place ?

Let's start this journey with below requirement.

Create a higher order function that accepts a react component. Do logs when life cycle methods (componentWillReceiveProps or render) are called

F1.js

export function hocF (Component) {
  const cwp = Component.prototype.componentWillReceiveProps;
  Component.prototype.componentWillReceiveProps = function(...args) {
    console.log('in Component will receive props....')
    cwp.call(this, ...args)
 }