🕵️ SicherheitslückenWhat continuous operational resilience looks like under DORA(09.09.2026 um 17:53 Uhr)
🔧 AI Nachrichten OpenAI seeks tougher AI rules. CIOs may feel the ripple effects(10.09.2026 um 12:11 Uhr)
🔧 AI Nachrichten Mistral valued at €21bn after €3bn Series D funding round(08.09.2026 um 10:19 Uhr)
🪟 Windows TippsWindows XP's Cursor Indicator Is Getting a Windows 11 Refresh(25.08.2026 um 13:00 Uhr)
🕵️ SicherheitslückenWhat continuous operational resilience looks like under DORA(09.09.2026 um 17:53 Uhr)
🔧 AI Nachrichten OpenAI seeks tougher AI rules. CIOs may feel the ripple effects(10.09.2026 um 12:11 Uhr)
🔧 AI Nachrichten Mistral valued at €21bn after €3bn Series D funding round(08.09.2026 um 10:19 Uhr)
🪟 Windows TippsWindows XP's Cursor Indicator Is Getting a Windows 11 Refresh(25.08.2026 um 13:00 Uhr)

🔧 Programmierung 🕛 vor 1 Jahr 3 Min Lesezeit
0

5 Javascript coding interview questions - Part 6

↗ Quelle (dev.to)
🗣️ Stimme:

Q1: What is the difference between let, const, and var?



Ans:




  • var: Function-scoped, can be redeclared, hoisted, and doesn’t support block scoping.

  • let: Block-scoped, can’t be redeclared in the same scope, hoisted but not initialized.

  • const: Block-scoped, must be initialized at declaration, hoisted but not initialized. its value cannot be reassigned.



const and let variables are hoisted, but they are not accessible before their declaration due to the temporal dead zone (TDZ).




CODE
// var example
if (true) {
var x = 10;
}
console.log(x); // 10

// let example
if (true) {
let y = 20;
console.log(y); // 20
}
// console.log(y); // ReferenceError: y is not defined

// const example
const z = 30;
// z = 40; // TypeError: Assignment to constant variable






Q2: What is Event Delegation in JavaScript?



Ans: Event Delegation is a technique in JavaScript where you add a single event listener to a parent element instead of adding multiple event listeners to child elements. The event listener on the parent element listens for events on its children using event bubbling.




CODE
// Add one event listener to the parent element
const parent = document.querySelector(".parent");

parent.addEventListener("click", (event) => {
if (event.target.classList.contains("child-button")) {
console.log(`Button ${event.target.textContent} clicked!`);
}
});

//HTML
<div class="parent">
<button class="child-button">Button 1</button>
<button class="child-button">Button 2</button>
<button class="child-button">Button 3</button>
</div>






Q3: What is the this keyword in JavaScript?



Ans: The value of this depends on the context:




  • In global scope, it refers to the global object (e.g., window in browsers).

  • Inside a function, it depends on how the function is called (e.g., in strict mode, it’s undefined by default).

  • Inside an object method, it refers to the object.

  • Inside an arrow function, it inherits this from the parent context.




CODE
const obj = {
name: 'JavaScript',
regularFunc() {
console.log(this.name); // 'JavaScript'
},
arrowFunc: () => {
console.log(this.name); // undefined (inherits from global scope)
},
};

obj.regularFunc();
obj.arrowFunc();






Q4: How do you flatten a deeply nested array in JavaScript?



Ans: You can use recursion or the Array.prototype.flat() method with an appropriate depth.




CODE
// Recursive function to flatten an array
function flattenArray(arr) {
return arr.reduce((acc, val) =>
Array.isArray(val) ? acc.concat(flattenArray(val)) : acc.concat(val), []);
}

const nestedArray = [1, [2, [3, [4, 5]]]];
console.log(flattenArray(nestedArray)); // [1, 2, 3, 4, 5]

// Using flat()
console.log(nestedArray.flat(Infinity)); // [1, 2, 3, 4, 5]






Q5: What is the difference between == and === in JavaScript?



Ans:




  • == compares values after performing type coercion.

  • === compares values and types without type coercion.




CODE
console.log(5 == '5');  // true (type coercion occurs)
console.log(5 === '5'); // false (no type coercion, types are different)

console.log(null == undefined); // true (both are loosely equal)
console.log(null === undefined); // false (different types)






5 Javascript coding interview questions - Part 5

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Sam Altman calls GPT-6 Astra rollout ‘messy’ as enterprise users wait for access
1 Quelle
Swiss government explores replacing Microsoft 365 with open-source software
1 Quelle
What continuous operational resilience looks like under DORA
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten 5 Javascript coding interview questions - Part 6

Thematisch verwandte Begriffe: Javascript, coding, interview, questions · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...