CoderRitik Official

CoderRitik Official Contact information, map and directions, contact form, opening hours, services, ratings, photos, videos and announcements from CoderRitik Official, Information Technology Company, Kanpur Nagar, Kanpur.

14/06/2026

Most developers get this wrong 🀯

This JavaScript destructuring example confuses many developers 😳

const obj = { x: 1, y: 2 };
const { x: y } = obj;
console.log(y);

πŸ‘‰ Output: 1

πŸ’‘ Why?
In object destructuring:
const { x: y } = obj;

means:
πŸ‘‰ Take the property "x"
πŸ‘‰ Store its value in a new variable called "y"

It's equivalent to:
const y = obj.x;

So: obj.x = 1

Therefore: console.log(y);

prints: 1

⚠️ Many developers think it accesses obj.y, but that's incorrect.

πŸ”₯ Common JavaScript interview question!

javascript destructuring example
object destructuring javascript
javascript aliasing destructuring
javascript interview question
js tricky questions
destructuring assignment explained
javascript output prediction
frontend interview questions
coding shorts javascript
learn javascript fast




24/05/2026

Copy or Reference? 🀯 JavaScript Explained

Description:-
This JavaScript object example looks simple but confuses many developers 😳

const a = { x: 1 };
const b = { ...a };

a.x = 10;

console.log(b.x);

πŸ‘‰ Output:
1

πŸ’‘ Why?

The spread operator (...) creates a NEW object by copying properties from "a".

So:
const b = { ...a };

creates a separate copy of the object.

After that:
a.x = 10

only changes object "a", NOT object "b".

πŸ‘‰ Therefore:
b.x is still 1

πŸ”₯ Important JavaScript concept for interviews:
Shallow copy vs reference copy.

javascript spread operator example
shallow copy javascript
object copy vs reference javascript
javascript object interview question
js tricky questions
spread operator explained
frontend interview questions
coding shorts javascript
learn javascript objects



17/05/2026

JavaScript Interview Question (await)

This JavaScript async/await example surprises many developers 😳

async function f() {
console.log(await 10);
}
f();

πŸ‘‰ Output:
10

πŸ’‘ Why does this work?

In JavaScript, "await" does NOT require a Promise.

If you await a normal value like a number, string, or object,
JavaScript automatically wraps it inside:

Promise.resolve(value)

So:
await 10

becomes:

await Promise.resolve(10)

πŸ‘‰ which resolves immediately and prints 10.

πŸ”₯ Important async/await concept for interviews!

javascript await example
await non promise javascript
async await javascript explained
javascript interview question async
await Promise.resolve example
js tricky questions
frontend interview questions
coding shorts javascript
learn async await




03/05/2026

JS Interview Question (function.length)

This JavaScript example tests your understanding of function properties 😳

function f(a, b, c) {
console.log(f.length);
}

f(1, 2, 3);

πŸ‘‰ Output:
3

πŸ’‘ Why?

The "length" property of a function returns the number of parameters
defined in the function, NOT the number of arguments passed.

Here:
function f(a, b, c)

πŸ‘‰ Total parameters = 3
So f.length = 3

Even if you pass more or fewer arguments,
f.length will still return the number of declared parameters.

πŸ”₯ Common JavaScript interview question!

javascript function length property
function length vs arguments javascript
javascript interview question function
js tricky questions
javascript function parameters explained
frontend developer interview
coding shorts javascript
learn javascript basics




29/04/2026

What will this print? 😳 (JS Rest Operator)

This JavaScript example tests your understanding of rest parameters 😳

function foo(a, ...rest) {
console.log(rest.length);
}

foo(1, 2, 3, 4, 5);

πŸ‘‰ Output:
4

πŸ’‘ Why?

The first argument (1) is assigned to "a".

All remaining arguments (2, 3, 4, 5) are collected into the "rest" array.

So:
rest = [2, 3, 4, 5]

πŸ‘‰ rest.length = 4

πŸ”₯ Rest parameters allow you to handle multiple arguments easily in JavaScript!

Common interview question for beginners πŸ‘€

javascript rest parameter example
rest operator javascript
javascript function arguments explained
js interview question beginner
rest vs spread javascript
javascript tricky questions
frontend interview questions
coding shorts javascript
learn javascript basics




26/04/2026

JS Interview Question (IIFE + Closure)

This JavaScript example looks tricky but is actually simple if you understand closures 😳

(function (x) {
return (function () {
console.log(x);
})();
})(10);

πŸ‘‰ Output:
10

πŸ’‘ Why?
Because of CLOSURE.

The inner function has access to the variable "x" from the outer function,
even after the outer function executes.

This is called lexical scope β€” a function remembers variables from where it was defined.

πŸ‘‰ Also, this is an IIFE (Immediately Invoked Function Expression),
which means the function runs instantly after being defined.

So:
- x = 10 is passed to outer function
- inner function uses closure to access x
- prints 10

πŸ”₯ Important JavaScript interview concept!

javascript closure example
iife javascript explained
javascript lexical scope
closure interview question javascript
js tricky questions
javascript scope explained
frontend developer interview
coding shorts javascript
learn javascript fast





24/04/2026

JS Trick: await on resolved promise ⚑

This JavaScript async/await example looks simple, but many developers misunderstand it 😳

async function f() {
return await Promise.resolve("hi");
}

f().then(console.log);

πŸ‘‰ Output:
hi

πŸ’‘ What’s happening here?

Promise.resolve("hi") already returns a resolved promise.
Using "await" here unwraps the value and returns "hi".

But since the function is async, it STILL returns a promise.

So this code is actually the same as:

async function f() {
return "hi";
}

πŸ‘‰ Both will print "hi"

⚠️ So why use await here?
In this case, it's unnecessary and adds no benefit.

βœ… Use await only when you need to handle async operations or errors.

πŸ”₯ Common async/await concept for interviews!

javascript async await example
promise resolve javascript
async await vs promise
javascript interview question async
await unnecessary example
javascript promises explained
js async basics
frontend interview questions
coding shorts javascript




22/04/2026

This async code doesn’t throw error 😳 Why?

This JavaScript async/await example confuses many developers 😳

async function f() {
return await new Error("fail");
}

f().then(console.log).catch(console.log);

πŸ‘‰ Output:
Error: fail

πŸ’‘ Why doesn't catch() run?

Because you are RETURNING an error, not THROWING it.

In JavaScript:
- return β†’ resolves the promise
- throw β†’ rejects the promise

Here, "return await new Error()" just resolves with an Error object,
so .then() runs instead of .catch()

βœ… Correct way:

async function f() {
throw new Error("fail");
}

Now .catch() will work properly.

πŸ”₯ Common async/await interview question!

javascript async await error
javascript throw vs return error
promise resolve vs reject
javascript interview question async
async await mistake
js error handling example
catch not working javascript
javascript debugging tips
web developer tricks




19/04/2026

var vs let in JavaScript (Mind Blowing Output!)

πŸ’‘ Why does this happen?

Because "var" is function-scoped, not block-scoped.
All the setTimeout callbacks share the SAME variable "i".

By the time setTimeout runs (after 1 second), the loop has already finished,
and the value of i becomes 6.

So every callback prints 6 instead of 1,2,3,4,5.

βœ… Fix:
Use "let" instead of "var"

for (let i = 1; i console.log(i), 1000);
}

Now each iteration has its own "i", so output will be:
1 2 3 4 5

πŸ”₯ This is a common JavaScript interview question!

javascript loop problem
var vs let javascript
javascript interview question
js tricky questions
async javascript example
setTimeout javascript loop
javascript closure explained
coding shorts
web developer tips
learn javascript fast





05/04/2026

JavaScript setTimeout in Loop Explained πŸ”₯ | Output Trick

Most beginners get this wrong 😳
setTimeout doesn’t stop the loop β€” it schedules it!
πŸ‘‰ Output prints after 1 second
Loop runs instantly πŸš€
setTimeout delays output ⏳
So numbers print after 1 sec β†’ 1 2 3 4 5 βœ…

Address

Kanpur Nagar
Kanpur

Website

Alerts

Be the first to know and let us send you an email when CoderRitik Official posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Shortcuts

Share