Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from sudheerj:master #100

Open
wants to merge 114 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
744cd4f
feat: add script to generate table of contents
yangshun Jun 3, 2024
6e6ef58
Update 206 README.md
Benappiahpoku Jun 6, 2024
b3963ae
Update Question 218 README.md
Benappiahpoku Jun 6, 2024
aa1ef0f
Merge pull request #263 from yangshun/ys/gen-toc
sudheerj Jun 7, 2024
fda0094
Merge pull request #266 from Benappiahpoku/patch-7
sudheerj Jun 7, 2024
4bf6838
Merge pull request #265 from Benappiahpoku/patch-6
sudheerj Jun 7, 2024
dc643af
github action to regenerate toc
yangshun Jun 7, 2024
35a866a
Update question 242 README.md
Benappiahpoku Jun 7, 2024
9fcce94
Update Question 251 README.md
Benappiahpoku Jun 7, 2024
0b3cb5b
Merge pull request #267 from yangshun/gh-action
sudheerj Jun 7, 2024
7a8eec2
[auto] regenerate table of contents
github-actions[bot] Jun 7, 2024
a334b4a
Merge pull request #268 from Benappiahpoku/patch-8
sudheerj Jun 7, 2024
e2489d3
Merge pull request #269 from Benappiahpoku/patch-9
sudheerj Jun 7, 2024
bc32d96
Update Question 280 README.md
Benappiahpoku Jun 9, 2024
446064d
Merge pull request #270 from Benappiahpoku/patch-10
sudheerj Jun 9, 2024
d456b47
+ Q451 Answer
AashishSinghal Jun 10, 2024
7f737c7
fixed minor Formatting on Q451
AashishSinghal Jun 10, 2024
0a208a2
Merge pull request #1 from AashishSinghal/AashishSinghal-451
AashishSinghal Jun 10, 2024
75958b7
Update Question 303 README.md
Benappiahpoku Jun 10, 2024
dcb3ba4
Merge pull request #272 from Benappiahpoku/patch-11
sudheerj Jun 10, 2024
c18a37c
Merge pull request #271 from AashishSinghal/master
sudheerj Jun 10, 2024
cb20a3e
Update question 307 README.md
Benappiahpoku Jun 11, 2024
f8cab3b
Update function-context.js
AyushJain-18 Jun 11, 2024
d6e4080
Merge pull request #274 from AyushJain-18/patch-1
sudheerj Jun 11, 2024
31e07df
Update slice method answer
sudheerj Jun 12, 2024
9e96819
Merge pull request #273 from Benappiahpoku/patch-12
sudheerj Jun 12, 2024
9b192d9
[auto] regenerate table of contents
github-actions[bot] Jun 12, 2024
c1cfe12
Update Question 349 README.md
Benappiahpoku Jun 12, 2024
9960652
Update 365 TOC and Question README.md
Benappiahpoku Jun 12, 2024
95d120a
Update TOC 365 README.md
Benappiahpoku Jun 12, 2024
14ee5c2
Merge pull request #275 from Benappiahpoku/patch-13
sudheerj Jun 12, 2024
68624a0
Merge pull request #276 from Benappiahpoku/patch-14
sudheerj Jun 12, 2024
312e71f
Update Question 391 & 396 README.md
Benappiahpoku Jun 13, 2024
cf54c10
Merge pull request #277 from Benappiahpoku/patch-15
sudheerj Jun 13, 2024
0e51965
Revert "Add GreatFrontEnd banner"
yangshun Jun 13, 2024
af949b5
Merge pull request #278 from yangshun/master
sudheerj Jun 13, 2024
2ceb1b6
Update Question 384 README.md
Benappiahpoku Jun 14, 2024
113cb6c
Update Question 383 README.md
Benappiahpoku Jun 14, 2024
543d1cd
Merge pull request #280 from Benappiahpoku/patch-17
sudheerj Jun 14, 2024
3d18a97
Merge pull request #279 from Benappiahpoku/patch-16
sudheerj Jun 14, 2024
2af2e41
Added hidden classes answer
sudheerj Jun 15, 2024
e8996fd
[auto] regenerate table of contents
github-actions[bot] Jun 15, 2024
34c0ef7
Add inline caching technique
sudheerj Jun 15, 2024
897d523
Merge branch 'master' of https://github.com/sudheerj/javascript-inter…
sudheerj Jun 15, 2024
ce67f39
Update Question 424 TOC and 431 README.md
Benappiahpoku Jun 15, 2024
438b99e
Merge pull request #281 from Benappiahpoku/patch-18
sudheerj Jun 16, 2024
7ed6644
[auto] regenerate table of contents
github-actions[bot] Jun 16, 2024
4d4f06b
Update GFE banner URL
yangshun Jun 19, 2024
b386048
Merge pull request #283 from yangshun/patch-1
sudheerj Jun 19, 2024
1277d66
Update Deno description
sudheerj Jun 27, 2024
7802ddf
Fixed tiny typos
Yuniac Jun 27, 2024
ca5e764
Merge pull request #285 from Yuniac/patch-1
sudheerj Jun 27, 2024
2b74a14
Add a question about executing external scripts
sudheerj Jun 29, 2024
f184322
[auto] regenerate table of contents
github-actions[bot] Jun 29, 2024
4f90367
Update GFE link
yangshun Jun 30, 2024
dcf140c
Update README.md
yangshun Jun 30, 2024
8f2f92b
Add matchMedia for dark mode
sudheerj Jul 1, 2024
8b2f086
[auto] regenerate table of contents
github-actions[bot] Jul 1, 2024
2532fcd
Lexical scope question added
muazimmaqbool Jul 3, 2024
e63b22b
Question link added
muazimmaqbool Jul 4, 2024
3784428
Update README.md
rakNeoQOWS101 Jul 4, 2024
adf2885
Merge pull request #288 from rakNeoQOWS101/patch-1
sudheerj Jul 5, 2024
c6bff48
Merge pull request #289 from muazimmaqbool/master
sudheerj Jul 5, 2024
1bd0655
[auto] regenerate table of contents
github-actions[bot] Jul 5, 2024
c654abf
Merge pull request #286 from yangshun/patch-2
sudheerj Jul 5, 2024
cca2d67
Coding question about sorting non-ASCII
sudheerj Jul 8, 2024
78ead63
Update README.md
SidharthArya Jul 8, 2024
1210f05
Question 157: fix punctuations
subhoghoshX Jul 8, 2024
12464ac
Question 185: fix console output
subhoghoshX Jul 8, 2024
f4a5e94
Question 228: add AggregateError
subhoghoshX Jul 8, 2024
2790651
Question 291: fix numbering
subhoghoshX Jul 8, 2024
0120a42
Question 303: fix typo
subhoghoshX Jul 8, 2024
6b15acc
Question 320: add new typed arrays
subhoghoshX Jul 8, 2024
8f5e0a5
Question 324: fix some subtle issues
subhoghoshX Jul 8, 2024
89459f3
Question 340: make example more clear
subhoghoshX Jul 8, 2024
c748597
Question 341: update answer with more concrete info
subhoghoshX Jul 8, 2024
d3d978e
Question 418: fix typo
subhoghoshX Jul 8, 2024
582f4a2
Question 421: make example match the answer
subhoghoshX Jul 8, 2024
feb4fd4
Question 454: JS string .some() method doesn't exist
subhoghoshX Jul 8, 2024
05ed546
Merge pull request #290 from SidharthArya/patch-1
sudheerj Jul 9, 2024
f7ddb9a
Merge pull request #291 from subhoghoshX/fix
sudheerj Jul 9, 2024
99b2e06
fix: Fixed numbering and redirection for Q465
manasvi-pandey Jul 9, 2024
c3d843f
Question 155: add other string methods that accept RegExp
subhoghoshX Jul 10, 2024
a8b1205
Merge pull request #293 from subhoghoshX/q-155
sudheerj Jul 10, 2024
c64d380
[auto] regenerate table of contents
github-actions[bot] Jul 10, 2024
2ec924d
Merge pull request #292 from manasvi-pandey/master
sudheerj Jul 10, 2024
5d06a92
[auto] regenerate table of contents
github-actions[bot] Jul 10, 2024
bbd51bf
added why forEach loop not returning undefined
sudo-abhinav Jul 17, 2024
a6b3707
Merge pull request #295 from sudo-abhinav/abhinav_branch
sudheerj Jul 18, 2024
940cb8b
Update cookies vs local storage vs session storage
sudheerj Aug 3, 2024
9bfc08e
Update README.md
Chaitanya-Raj Aug 5, 2024
c51605d
Merge pull request #296 from Chaitanya-Raj/patch-1
sudheerj Aug 5, 2024
beef0ed
[auto] regenerate table of contents
github-actions[bot] Aug 5, 2024
11275f5
Add function length question
sudheerj Aug 12, 2024
fb5c39d
[auto] regenerate table of contents
github-actions[bot] Aug 12, 2024
7e9b57c
Add arguments coding question
sudheerj Aug 13, 2024
14ddea5
Merge branch 'master' of https://github.com/sudheerj/javascript-inter…
sudheerj Aug 13, 2024
f16bfb8
Fix typos
sudheerj Aug 13, 2024
24f0468
Fix code alignment issues
sudheerj Aug 18, 2024
d129186
Fix formatting issues
sudheerj Aug 23, 2024
6e8edf6
[auto] regenerate table of contents
github-actions[bot] Aug 23, 2024
b549f8e
Add globalThis question
sudheerj Sep 1, 2024
19bdba0
Add globalThis question
sudheerj Sep 1, 2024
a5cf154
[auto] regenerate table of contents
github-actions[bot] Sep 1, 2024
a6866c0
Create FUNDING.yml
sudheerj Sep 18, 2024
2f9f5a5
Array mutation methods
sudheerj Sep 18, 2024
eddd96e
Merge branch 'master' of https://github.com/sudheerj/javascript-inter…
sudheerj Sep 18, 2024
a839cd1
[auto] regenerate table of contents
github-actions[bot] Sep 18, 2024
d57e5d5
doc: update question 467 substr vs substring
mauroaccornero Sep 17, 2024
4169096
Merge pull request #298 from mauroaccornero/update-question-467
sudheerj Oct 10, 2024
4e4df97
Update README.md
ckpinguin Nov 13, 2024
b13c320
Merge pull request #299 from ckpinguin/patch-1
sudheerj Nov 15, 2024
1d8b813
Update README.md
dharapj Jan 21, 2025
34549e3
Merge pull request #303 from dharapj/patch-1
sudheerj Feb 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: [sudheerj]
custom: https://buymeacoffee.com/sudheerj
36 changes: 36 additions & 0 deletions .github/workflows/gen-toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Generate table of contents

on:
pull_request:
push:
branches:
- master

env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
gen-toc:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Install dependencies
run: npm install
- name: Generate table of contents
run: npm run gen
- name: 'Commit changes if required'
run: |
if ! git diff --quiet README.md; then
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "GitHub Actions"
git add README.md
git commit -m "[auto] regenerate table of contents"
git push
echo "[info] Table of contents updated and committed."
else
echo "[info] No changes to table of contents."
fi
working-directory: ${{ github.workspace }}
134 changes: 132 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,134 @@
# Cruft
.DS_Store
npm-debug.log
.idea
.idea

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
1,880 changes: 1,160 additions & 720 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion coding-exercise/function-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ function User(name, age) {

var user = new User('John', 25);
var profile = user.getProfile();
profile(); //I'm undefined, undefined yrs old
profile(); //I'm , undefined yrs old
1 change: 0 additions & 1 deletion images/collab/codestudio-logo.svg

This file was deleted.

Binary file added images/collab/frontendlead-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/collab/greatfrontend-js-banner4x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "javascript-interview-questions",
"version": "1.0.0",
"description": "List of 1000 JavaScript Interview Questions",
"author": "Sudheer Jonna",
"scripts": {
"gen": "node scripts/toc.mjs"
},
"dependencies": {
"github-slugger": "^2.0.0"
}
}
86 changes: 86 additions & 0 deletions scripts/toc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import GitHubSlugger from "github-slugger";
import fs from "fs";
import path, { dirname } from "path";
import { fileURLToPath } from "url";

const slugger = new GitHubSlugger();

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const filePath = path.join(__dirname, "../README.md");

const TOC_START_MARKER = "<!-- TOC_START -->";
const TOC_END_MARKER = "<!-- TOC_END -->";
const QUESTIONS_START_MARKER = "<!-- QUESTIONS_START -->";
const QUESTIONS_END_MARKER = "<!-- QUESTIONS_END -->";
const QUESTION_TITLE_HEADING_LEVEL = "###";

const rawFile = fs.readFileSync(filePath).toString();

const fileAsLines = rawFile.split("\n");

const tocStartIndex = fileAsLines.findIndex(
(line) => line === TOC_START_MARKER
);
const tocEndIndex = fileAsLines.findIndex((line) => line === TOC_END_MARKER);

const questionsStartIndex = fileAsLines.findIndex(
(line) => line === QUESTIONS_START_MARKER
);
const questionsEndIndex = fileAsLines.findIndex(
(line) => line === QUESTIONS_END_MARKER
);

if (
[tocStartIndex, tocEndIndex, questionsStartIndex, questionsEndIndex].some(
(index) => index === -1
)
) {
throw "One of the crucial indices markers not found";
}

const questions = [];
let currentQuestion = 0;

// Collect the question titles and numbers into an array.
// Also automatically renames the title line if the number is out-of-order.
for (
let lineNumber = questionsStartIndex;
lineNumber < questionsEndIndex;
lineNumber++
) {
const line = fileAsLines[lineNumber];
if (line.includes(` ${QUESTION_TITLE_HEADING_LEVEL} `)) {
currentQuestion++;
const lineParts = line.split(` ${QUESTION_TITLE_HEADING_LEVEL} `);
const questionTitle = lineParts[1];
const questionSlug = slugger.slug(questionTitle);
questions.push({
number: currentQuestion,
title: questionTitle,
slug: questionSlug,
});

fileAsLines[lineNumber] =
currentQuestion + `. ${QUESTION_TITLE_HEADING_LEVEL} ` + questionTitle;
}
}

// Create lines for table of contents using the collected questions.
const tableOfContentsLines = ["| No. | Questions |", "| --- | --------- |"];

questions.forEach(({ number, title, slug }) =>
tableOfContentsLines.push(`| ${number} | [${title}](#${slug}) |`)
);

// Create resulting file and write to file system.
const outputFileLines = [
...fileAsLines.slice(0, tocStartIndex + 1),
...tableOfContentsLines,
...fileAsLines.slice(tocEndIndex),
];

const outputFile = outputFileLines.join("\n");

fs.writeFileSync(filePath, outputFile);
console.info(`Processed ${tableOfContentsLines.length} questions.`);