Javascript Interview Questions

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Describe 3 es2015 features and how they differ from ES5.

1. Arrow function > Function 2. Destructuring > Listing variables 3. Spread Operator > Object.assign() For an extensive list, visit: http://es6-features.org/

Describe closures and why they are important.

A closure is a function that references a variable defined in a parent/ancestor scope. Important for when you ever need a default variable or value.

What's the difference between a for loop and a for in loop?

A for loop iterates through an array a number of times. A for/in loop iterates through the properties of an object.

What's the difference between == and === in JavaScript?

Both are comparison operators. == only compares values when called. ===, commonly referred to as the "strict comparison operator", compares values and data types to ensure an exact match.

Describe square bracket notation and when you would use it (hint arrays and objects).

Bracket notation is one way to access key property values in objects and arrays.

What is hoisting?

In JavaScript, a variable can be used before it has been declared. This behavior of moving declarations to the top is referred to as Hoisting.

Describe how scoping works in JavaScript.

In JavaScript, there are two types of scope: Local and Global scope. Scope determines the accessibility (visibility) of variables. Each function creates a new scope. Variables defined inside a function are not accessible (visible) from outside the function.

What does the statement 'use strict' do?

Indicates that the code should be executed in "strict mode". You can not, for example, use undeclared variables. For more information, visit: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode

What is a prototype in JavaScript?

It is an object Javascript adds to every function that holds a constructor property pointing back to the function by default.

Explain let vs var.

The difference is scoping. Let is scoped to the nearest enclosing block (which can be smaller than a function block). Var is scoped to the nearest function block. **Both are global if outside of any block.

Describe context.

Unlike scope, context refers to the object to which a function belongs.

Explain how to handle errors in JS.

Use a "try catch" block or append a ".catch" depending on the returning information.

How does inheritance work in JavaScript?

When one object acquires the properties and behaviors of another object by calling the prototype object. Parent to child inheritance.

What is event bubbling in the DOM?

When the event is first captured and handled by the innermost element and then propagated to outer elements. Visit this site for a great tutorial on Bubbling. https://javascript.info/bubbling-and-capturing


Kaugnay na mga set ng pag-aaral

CITI social and behavioral research

View Set

Chapter 12 Test, (1930s America: The New Deal)

View Set

Health Assessment Chapter 11 Questions

View Set

Chapter 21: Respiratory Care Modalities

View Set

Pediatric HESI Practice Questions

View Set