├── .templates
├── react-constant
│ ├── constant.js
│ ├── hooks.jsx
│ └── index.jsx
└── react-basic
│ ├── hooks.jsx
│ └── index.jsx
├── prototype.js
├── 11.jpg
├── 12.jpg
├── 13.jpg
├── 14.jpg
├── 15.jpg
├── 16.jpg
├── 17.jpg
├── 18.jpg
├── 19.jpg
├── 110.jpg
├── 112.jpg
├── 113.jpg
├── 115.jpg
├── 116.jpg
├── 117.jpg
├── 118.jpg
├── React-Tutorials-main
├── public
│ ├── robots.txt
│ ├── favicon.ico
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ └── index.html
├── src
│ ├── App.js
│ ├── setupTests.js
│ ├── components
│ │ ├── ErrorBoundaries
│ │ │ ├── ErrorDemo.js
│ │ │ ├── CounterDemo.js
│ │ │ └── ErrorBoundaries.js
│ │ ├── Ref
│ │ │ ├── ChildRef.js
│ │ │ ├── ParentRef.js
│ │ │ └── RefDemo.js
│ │ ├── Fragments
│ │ │ ├── Columns.js
│ │ │ ├── TableDemo.js
│ │ │ ├── FragmentDemo.js
│ │ │ └── ListDemo.js
│ │ ├── Event Handling
│ │ │ ├── ChildofClassComponent.js
│ │ │ ├── FunctionalComponent.js
│ │ │ └── ClassComponent.js
│ │ ├── Portals
│ │ │ ├── ChildComponent.js
│ │ │ └── ParentComponent.js
│ │ ├── HOC
│ │ │ ├── CommentsCount.js
│ │ │ ├── LikesCount.js
│ │ │ └── HOC.js
│ │ ├── Props
│ │ │ ├── Cars.js
│ │ │ └── CarDetails.js
│ │ ├── PureComponent
│ │ │ ├── NormalComponent.js
│ │ │ └── PureComponents.js
│ │ ├── Lifecycle Methods
│ │ │ ├── DisplayClock.js
│ │ │ └── Clock.js
│ │ ├── Conditional Rendering
│ │ │ └── ConditionalRendering.js
│ │ ├── Forms
│ │ │ └── DemoForm.js
│ │ └── API
│ │ │ └── FetchApi.js
│ ├── App.test.js
│ ├── index.css
│ ├── index.js
│ ├── App.css
│ ├── logo.svg
│ └── serviceWorker.js
├── .gitignore
├── package.json
└── README.md
├── README.md
├── dvh lvh svh in css.png
├── Javascript
├── scrollTop.js
├── randomRender.js
├── sort.js
├── bgHalf.css
├── IIFE.JS
├── first-class entity.js
├── data-destructuring.js
├── Currying_ChainClosure.js
├── null vs undefined.js
├── closure.js
├── for.js
├── prevState.js
├── HOF.js
├── msgChatScrollBottom.jsx
├── value_refrence_type.js
├── filter.js
├── callback.js
├── callStack.js
├── object.keys.js
├── outside.js
├── var const let.js
├── classes.js
├── reduce.js
├── promis.js
├── this.js
├── callBackOther.js
├── jsMethods.js
└── checkBoxburgerIcon.html
├── javascript_interview_bank-main.zip
├── Interview questions [candidate edition].pdf
├── Novoresume - Your guide to Getting Hired in 2022.pdf
├── Screenshot_2023-07-05-08-35-10-902_com.linkedin.android.jpg
├── Screenshot_2023-07-05-10-43-19-982_com.linkedin.android.jpg
├── Screenshot_2023-07-05-10-44-20-226_com.linkedin.android.jpg
├── Screenshot_2023-07-05-10-46-43-516_com.linkedin.android.jpg
├── persian-articles-website.txt
├── reactQuery-keys.ts
├── React js
├── ForwardingRef.jsx
├── Ref.jsx
├── LifeCycle.jsx
├── Responsive.css
├── Portals.jsx
├── Error Boundary.jsx
├── useMemo useCallback.js
├── Responsive.jsx
├── React-Lazy.jsx
├── useDebounce.jsx
└── Controlled Uncontrolled Components.jsx
├── font-preload.js
├── remove_duplicates.js
├── iphone zoom disable.css
├── local-fonts.js
├── nextjs-tips.txt
├── debounceFn.js
├── testing.js
├── useDebounce.jsx
├── useGeoLocation.tsx
├── re-render.isx
├── useDebounce-typescript.tsx
├── template.config.js
├── bind_call_apply.js
├── testing-persian.js
├── utils.ts
├── mock api vs real api.txt
└── task-doc.md
/.templates/react-constant/constant.js:
--------------------------------------------------------------------------------
1 | const test = "test";
2 |
--------------------------------------------------------------------------------
/prototype.js:
--------------------------------------------------------------------------------
1 | https://ditty.ir/courses/javascript/prototypes/nYLA5
2 |
--------------------------------------------------------------------------------
/11.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/11.jpg
--------------------------------------------------------------------------------
/12.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/12.jpg
--------------------------------------------------------------------------------
/13.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/13.jpg
--------------------------------------------------------------------------------
/14.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/14.jpg
--------------------------------------------------------------------------------
/15.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/15.jpg
--------------------------------------------------------------------------------
/16.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/16.jpg
--------------------------------------------------------------------------------
/17.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/17.jpg
--------------------------------------------------------------------------------
/18.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/18.jpg
--------------------------------------------------------------------------------
/19.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/19.jpg
--------------------------------------------------------------------------------
/110.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/110.jpg
--------------------------------------------------------------------------------
/112.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/112.jpg
--------------------------------------------------------------------------------
/113.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/113.jpg
--------------------------------------------------------------------------------
/115.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/115.jpg
--------------------------------------------------------------------------------
/116.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/116.jpg
--------------------------------------------------------------------------------
/117.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/117.jpg
--------------------------------------------------------------------------------
/118.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/118.jpg
--------------------------------------------------------------------------------
/React-Tutorials-main/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-javascript-interview-codes
2 |
3 | js interview codes
4 |
5 | react interview codes
6 |
7 |
--------------------------------------------------------------------------------
/dvh lvh svh in css.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/dvh lvh svh in css.png
--------------------------------------------------------------------------------
/Javascript/scrollTop.js:
--------------------------------------------------------------------------------
1 | function scrollTop() {
2 | window.scrollTo({
3 | top: 0,
4 | behavior: "smooth",
5 | });
6 | }
7 |
--------------------------------------------------------------------------------
/javascript_interview_bank-main.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/javascript_interview_bank-main.zip
--------------------------------------------------------------------------------
/Javascript/randomRender.js:
--------------------------------------------------------------------------------
1 | const num = [6, 3, 5, 9, 1];
2 |
3 | const random = num.sort((a, b) => Math.random() - 0.5);
4 |
5 | console.log(random);
6 |
--------------------------------------------------------------------------------
/React-Tutorials-main/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/React-Tutorials-main/public/favicon.ico
--------------------------------------------------------------------------------
/React-Tutorials-main/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/React-Tutorials-main/public/logo192.png
--------------------------------------------------------------------------------
/React-Tutorials-main/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/React-Tutorials-main/public/logo512.png
--------------------------------------------------------------------------------
/Interview questions [candidate edition].pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/Interview questions [candidate edition].pdf
--------------------------------------------------------------------------------
/Javascript/sort.js:
--------------------------------------------------------------------------------
1 | // sort method
2 | const number = [1, 6, 2, 4, 9, 7, 5];
3 | const sorted = number.sort((a, b) => {
4 | return a - b;
5 | });
6 | console.log("sorted :", sorted);
7 |
--------------------------------------------------------------------------------
/Novoresume - Your guide to Getting Hired in 2022.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/Novoresume - Your guide to Getting Hired in 2022.pdf
--------------------------------------------------------------------------------
/Screenshot_2023-07-05-08-35-10-902_com.linkedin.android.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/Screenshot_2023-07-05-08-35-10-902_com.linkedin.android.jpg
--------------------------------------------------------------------------------
/Screenshot_2023-07-05-10-43-19-982_com.linkedin.android.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/Screenshot_2023-07-05-10-43-19-982_com.linkedin.android.jpg
--------------------------------------------------------------------------------
/Screenshot_2023-07-05-10-44-20-226_com.linkedin.android.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/Screenshot_2023-07-05-10-44-20-226_com.linkedin.android.jpg
--------------------------------------------------------------------------------
/Screenshot_2023-07-05-10-46-43-516_com.linkedin.android.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EsrafilElahi/react-javascript-interview-codes/HEAD/Screenshot_2023-07-05-10-46-43-516_com.linkedin.android.jpg
--------------------------------------------------------------------------------
/Javascript/bgHalf.css:
--------------------------------------------------------------------------------
1 | body {
2 | width: 100%;
3 | height: 100vh;
4 | background: linear-gradient(
5 | to right,
6 | pink 0%,
7 | pink 50%,
8 | aqua 50%,
9 | aqua 100%
10 | )
11 | }
--------------------------------------------------------------------------------
/.templates/react-basic/hooks.jsx:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from 'react';
2 |
3 | function use__templateNameToPascalCase__() {
4 |
5 | return {}
6 | }
7 |
8 | export default use__templateNameToPascalCase__;
9 |
--------------------------------------------------------------------------------
/.templates/react-constant/hooks.jsx:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from 'react';
2 |
3 | function use__templateNameToPascalCase__() {
4 |
5 | return {}
6 | }
7 |
8 | export default use__templateNameToPascalCase__;
9 |
--------------------------------------------------------------------------------
/Javascript/IIFE.JS:
--------------------------------------------------------------------------------
1 | // IIFE
2 | (function home(ax) {
3 | console.log(ax);
4 | })(12);
5 | (hend = (hendi) => {
6 | console.log("hend is :", hendi);
7 | })("indian");
8 | (function (param) {
9 | console.log("name :", param);
10 | })("ali");
11 |
--------------------------------------------------------------------------------
/persian-articles-website.txt:
--------------------------------------------------------------------------------
1 | https://amirsalehi.ir/blog/
2 | https://greenonsoftware.com/articles/integrations/how-to-integrate-state-management-in-zustand-with-nextjs/
3 | https://greenonsoftware.com/articles/react/common-mistakes-in-using-react-context-api/
4 |
--------------------------------------------------------------------------------
/.templates/react-basic/index.jsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | function __templateNameToPascalCase__() {
4 | return (
5 |
6 | __templateNameToPascalCase__
7 |
8 | )
9 | }
10 |
11 | export default __templateNameToPascalCase__;
12 |
--------------------------------------------------------------------------------
/.templates/react-constant/index.jsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | function __templateNameToPascalCase__() {
4 | return (
5 |
6 | __templateNameToPascalCase__
7 |
8 | )
9 | }
10 |
11 | export default __templateNameToPascalCase__;
12 |
--------------------------------------------------------------------------------
/Javascript/first-class entity.js:
--------------------------------------------------------------------------------
1 | // first-class entity
2 | const hello = () => {
3 | console.log("hello f-c");
4 | };
5 |
6 | function say(handler) {
7 | handler();
8 |
9 | return function () {
10 | console.log("goodbye f-c");
11 | };
12 | }
13 |
14 | console.log(say(hello)());
15 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/App.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import "./App.css";
3 | import FetchAPI from "./components/API/FetchApi";
4 |
5 | function App() {
6 | return (
7 |
8 |
9 |
10 | );
11 | }
12 |
13 | export default App;
14 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom/extend-expect';
6 |
--------------------------------------------------------------------------------
/Javascript/data-destructuring.js:
--------------------------------------------------------------------------------
1 | const num = [1, 2, 3, 4];
2 |
3 | const [a, b, ...rest] = num;
4 |
5 | console.log(a, b, rest);
6 |
7 | // ============================
8 |
9 | const user = {
10 | name: "eliot",
11 | age: 23,
12 | };
13 |
14 | const { name } = user;
15 |
16 | console.log(name);
17 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/components/ErrorBoundaries/ErrorDemo.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | function ErrorDemo(props) {
4 | if (props.name != "codebucks") {
5 | throw new Error("There is an Error!");
6 | }
7 |
8 | return {props.name}
;
9 | }
10 |
11 | export default ErrorDemo;
12 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/components/Ref/ChildRef.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | const ChildRef = React.forwardRef((props, ref) => (
4 |
5 |
Child Ref:
6 |
7 |
8 | ));
9 |
10 | export default ChildRef;
11 |
--------------------------------------------------------------------------------
/Javascript/Currying_ChainClosure.js:
--------------------------------------------------------------------------------
1 | const sum = (a) => {
2 | return (sum1 = (b) => {
3 | return (sum2 = (c) => {
4 | return a + b + c;
5 | });
6 | });
7 | };
8 |
9 | console.log(sum(2)(1)(3));
10 |
11 | const sum1 = sum(1);
12 | const sum2 = sum1(6);
13 | const result = sum2(4);
14 | console.log(result);
15 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/components/Fragments/Columns.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from "react";
2 |
3 | export default class Columns extends Component {
4 | render() {
5 | return (
6 |
7 | Hello |
8 | World |
9 |
10 | );
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/reactQuery-keys.ts:
--------------------------------------------------------------------------------
1 | const userKeys = {
2 | all: ['users'] as const,
3 | lists: () => [...userKeys.all, 'list'] as const,
4 | list: (filters: string) => [...userKeys.lists(), { filters }] as const,
5 | details: () => [...userKeys.all, 'detail'] as const,
6 | detail: (id: number) => [...userKeys.details(), id] as const,
7 | };
8 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/App.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { render } from '@testing-library/react';
3 | import App from './App';
4 |
5 | test('renders learn react link', () => {
6 | const { getByText } = render();
7 | const linkElement = getByText(/learn react/i);
8 | expect(linkElement).toBeInTheDocument();
9 | });
10 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/components/Event Handling/ChildofClassComponent.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from "react";
2 |
3 | export default class ChildofClassComponent extends Component {
4 | render() {
5 | return (
6 |
7 |
8 |
9 | );
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/components/Fragments/TableDemo.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from "react";
2 | import Columns from "./Columns";
3 |
4 | export default class TableDemo extends Component {
5 | render() {
6 | return (
7 |
12 | );
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/React js/ForwardingRef.jsx:
--------------------------------------------------------------------------------
1 | // برای انتقال رف از یک کامپوننت به یک کامپوننت دیگر
2 |
3 | const FancyButton = React.forwardRef((props, ref) => (
4 |
7 | ));
8 |
9 | // You can now get a ref directly to the DOM button:
10 | const ref = React.createRef();
11 | Click me!;
--------------------------------------------------------------------------------
/Javascript/null vs undefined.js:
--------------------------------------------------------------------------------
1 | const user = {};
2 | console.log(user.name); // undefined
3 |
4 | let x;
5 | console.log(x); // undefined
6 |
7 | function person() {
8 | // no return
9 | }
10 | console.log(person()); // undefined
11 |
12 | nul == undefined; // true
13 | nul === undefined; // false
14 |
15 | console.log(typeof undefined); // undefined
16 | console.log(typeof null); // object
17 |
--------------------------------------------------------------------------------
/React js/Ref.jsx:
--------------------------------------------------------------------------------
1 | // به مقادیر یک المنت دسترسی داشته باشیم
2 |
3 | import React, { useRef, useEffect } from "react";
4 |
5 | function Ref() {
6 | const inputRef = useRef();
7 |
8 | useEffect(() => {
9 | inputRef.current.focus();
10 | });
11 |
12 | return (
13 |
14 |
15 |
16 | );
17 | }
18 |
19 | export default Ref;
20 |
--------------------------------------------------------------------------------
/Javascript/closure.js:
--------------------------------------------------------------------------------
1 | function init() {
2 | var count = 0;
3 |
4 | return function () {
5 | count++;
6 | return count;
7 | };
8 | }
9 |
10 | const jump = init();
11 | const fly = init();
12 |
13 | console.log(jump());
14 | console.log(jump());
15 | console.log("==========");
16 | console.log(fly());
17 | console.log(fly());
18 | console.log(!!init); // will be true --> !! Bolean mikone
19 |
--------------------------------------------------------------------------------
/font-preload.js:
--------------------------------------------------------------------------------
1 | // in nextjs --> _app.js
2 |
9 |
10 | // in nextjs --> _document.js
11 |
18 |
--------------------------------------------------------------------------------
/React-Tutorials-main/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/components/Portals/ChildComponent.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from "react";
2 | import ReactDOM from "react-dom";
3 |
4 | export default class ChildComponent extends Component {
5 | render() {
6 | return ReactDOM.createPortal(
7 |
8 |
9 |
,
10 |
11 | document.getElementById("portal")
12 | );
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/components/Fragments/FragmentDemo.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from "react";
2 | import TableDemo from "./TableDemo";
3 | import ListDemo from "./ListDemo";
4 |
5 | export default class FragmentDemo extends Component {
6 | render() {
7 | return (
8 | <>
9 | This is Fragment Demo!
10 |
11 |
12 | >
13 | );
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/Javascript/for.js:
--------------------------------------------------------------------------------
1 | // for in --> return index
2 | const number = [2, 6, 4, 8, 1];
3 | for (const index in number) {
4 | console.log(number[index]);
5 | }
6 |
7 | const obj = {
8 | name: "abraham",
9 | age: 25,
10 | country: "england",
11 | };
12 | for (const key in obj) {
13 | console.log(key); // key
14 | console.log(obj[key]); //value
15 | }
16 |
17 |
18 | // for of --> return item
19 | const num = [0, 7, 4, 9, 2];
20 | for (const item of num) {
21 | console.log(item);
22 | }
23 |
--------------------------------------------------------------------------------
/Javascript/prevState.js:
--------------------------------------------------------------------------------
1 | const [num, setNum] = useState(0);
2 |
3 | const handleClick = () => {
4 | setNum(num + 1);
5 | setNum(num + 1); // faghat 1 doone ezaf mishe
6 | setNum(num + 1);
7 | };
8 |
9 | const handleClick2 = () => {
10 | setNum((prevState) => prevState + 1);
11 | setNum((prevState) => prevState + 1); // intori 3ta 3ta ezaf mishe
12 | setNum((prevState) => prevState + 1);
13 | };
14 |
15 | // har mooghe be meghdar ghabli state niaz dashtim az prevState estefade mikonim
16 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/components/HOC/CommentsCount.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from "react";
2 | import HOC from "./HOC";
3 |
4 | class CommentsCount extends Component {
5 | render() {
6 | return (
7 |
8 | Total Comments : {this.props.CountNumber}
9 |
10 |
11 | );
12 | }
13 | }
14 |
15 | const EnhancedComments = HOC(CommentsCount, 10);
16 |
17 | export default EnhancedComments;
18 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/components/Event Handling/FunctionalComponent.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | export default function FunctionalComponent() {
4 | function clickHandler(event) {
5 | event.preventDefault();
6 | console.log("Form is Submitted!");
7 | }
8 |
9 | return (
10 |
11 |
15 |
16 | );
17 | }
18 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/components/HOC/LikesCount.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from "react";
2 | import HOC from "./HOC";
3 |
4 | class LikesCount extends Component {
5 | render() {
6 | return (
7 |
8 | Hello {this.props.username}.
9 | {this.props.CountNumber}
10 |
11 |
12 | );
13 | }
14 | }
15 |
16 | const EnhancedLikes = HOC(LikesCount, 5);
17 |
18 | export default EnhancedLikes;
19 |
--------------------------------------------------------------------------------
/Javascript/HOF.js:
--------------------------------------------------------------------------------
1 | // HOF --> higher order function
2 |
3 | // const adder = (a) => {
4 | // return function (n) {
5 | // return a + n
6 | // }
7 | // }
8 | // const add5 = adder(5)
9 | // console.log('adder :', add5(5))
10 |
11 | const newPush = (value) => {
12 | return (arr) => {
13 | const clone = [...arr, value];
14 | return clone;
15 | };
16 | };
17 |
18 | const push1 = newPush(5);
19 | const arr = [1, 2, 3, 4];
20 |
21 | console.log("arr :", arr);
22 | console.log("push1 :", push1(arr));
23 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/index.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom";
3 | import "./index.css";
4 | import App from "./App";
5 | import * as serviceWorker from "./serviceWorker";
6 |
7 | ReactDOM.render(, document.getElementById("root"));
8 |
9 | // If you want your app to work offline and load faster, you can change
10 | // unregister() to register() below. Note this comes with some pitfalls.
11 | // Learn more about service workers: https://bit.ly/CRA-PWA
12 | serviceWorker.unregister();
13 |
--------------------------------------------------------------------------------
/Javascript/msgChatScrollBottom.jsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useRef } from 'react'
2 |
3 | const Messages = ({ messages }) => {
4 |
5 | const messagesEndRef = useRef(null)
6 |
7 | const scrollToBottom = () => {
8 | messagesEndRef.current.scrollIntoView({ behavior: "smooth" })
9 | }
10 |
11 | useEffect(scrollToBottom, [messages]);
12 |
13 | return (
14 |
15 | {messages.map(message =>
)}
16 |
17 |
18 | )
19 | }
20 |
--------------------------------------------------------------------------------
/remove_duplicates.js:
--------------------------------------------------------------------------------
1 | const numbers = [3, 4, 2, 3, 7, 3];
2 |
3 | const filterArr2 = numbers.filter((item, index, arr) => arr.indexOf(item) === index) // way 1
4 |
5 | const filterArr3 = [...new Set(numbers)] // way 2
6 |
7 | const filterArr4 = numbers.reduce((acc, val) => {
8 | acc.includes(val) ? acc : [...acc, val]
9 | },[]) // way 3
10 |
11 | // array of obj
12 | const removeDuplicatedArrObj = products?.filter(
13 | (firstValue, index, array) =>
14 | index === array?.findIndex((secondValue) => secondValue?.productId === firstValue?.productId)
15 | );
16 |
--------------------------------------------------------------------------------
/Javascript/value_refrence_type.js:
--------------------------------------------------------------------------------
1 | // --------> primitive type (value type) = doesn't change
2 | // let x = 10;
3 | // let x = 'one';
4 | // let x = null;
5 | // let x = false;
6 |
7 | // let y = x;
8 |
9 | // x = 20;
10 | // x = 'two';
11 | // x = undefined;
12 | // x = true;
13 |
14 | // --------> refrence type = gonna change
15 | // let x = {val: 10};
16 | // let x = [10]
17 | // function x() {
18 | // return 10;
19 | // }
20 |
21 | // let y = x;
22 |
23 | // x.val = 20;
24 | // x[0] = 20;
25 | // function x() {
26 | // return 20;
27 | // }
28 |
29 | // console.log(y())
30 | // console.log(y)
31 |
--------------------------------------------------------------------------------
/React js/LifeCycle.jsx:
--------------------------------------------------------------------------------
1 | // Mounting ---> component will ready to run in the DOM
2 | // Updating ---> update component with state - props
3 | // Unmounting ---> remove the component from DOM
4 |
5 | // ====================================
6 |
7 | //Mount
8 | // 1- constructor()
9 | // 2- static getDerivedStateFormProps()
10 | // 3- render()
11 | // 4- componentDidMount()
12 |
13 | // Updating
14 | // 1- static getDerivedStateFromProps()
15 | // 2- shouldComponentUpdate()
16 | // 3- render()
17 | // 4- getSnapshotsBeforeUpdating()
18 | // 5- componentDidUpdate()
19 |
20 | // Unmount
21 | // 1- componentWillUnmount()
22 |
--------------------------------------------------------------------------------
/Javascript/filter.js:
--------------------------------------------------------------------------------
1 | // filter
2 | const filter = (array, conditionFunc) => {
3 | if (
4 | !Array.isArray(array) ||
5 | array.length === 0 ||
6 | typeof conditionFunc !== "function"
7 | ) {
8 | return [];
9 | }
10 |
11 | const result = [];
12 | // for (const item of array) {
13 | for (const index in array) {
14 | if (conditionFunc(array[index])) {
15 | result.push(array[index]);
16 | }
17 | }
18 |
19 | return result;
20 | };
21 |
22 | const testFilter = filter([1, 2, 3, 4], function (item, index, array) {
23 | return item % 2 === 0;
24 | });
25 | console.log("test filter :", testFilter);
26 |
--------------------------------------------------------------------------------
/React-Tutorials-main/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/components/Portals/ParentComponent.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from "react";
2 | import ChildComponent from "./ChildComponent";
3 |
4 | export default class ParentComponent extends Component {
5 | constructor(props) {
6 | super(props);
7 |
8 | this.state = {
9 | count: 0,
10 | };
11 | }
12 |
13 | onIncrement = () => {
14 | this.setState({ count: this.state.count + 1 });
15 | };
16 |
17 | render() {
18 | return (
19 |
20 | Count Number: {this.state.count}
21 |
22 |
23 | );
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/React-Tutorials-main/src/components/Props/Cars.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import CarDetails from "./CarDetails";
3 |
4 | const carObj = {
5 | name: "Audi A5",
6 | color: "black",
7 | type: "sedan",
8 | };
9 |
10 | export default function Cars() {
11 | return (
12 |
13 | {/* //Child component to render Car Details */}
14 |
15 |
16 | {/*
17 |
18 |
19 | */}
20 |
21 | );
22 | }
23 |
--------------------------------------------------------------------------------
/React js/Responsive.css:
--------------------------------------------------------------------------------
1 | @media (max-width: 480px) {
2 | .bala {
3 | color: red;
4 | }
5 |
6 | .paiin {
7 | color: chartreuse;
8 | }
9 | }
10 |
11 | @media (min-width: 480px) {
12 | .bala {
13 | color: aqua;
14 | }
15 |
16 | .paiin {
17 | color: blue;
18 | }
19 | }
20 |
21 | /*
22 |
23 |
24 |
25 | bala
26 |
27 | Resize the browser window. When the width of this document is 600 pixels or less, the background-color is "lightblue", otherwise it is "lightgreen".
28 |
29 | paiin
30 |
31 |
32 |
33 |