The Basics

What is Javascript?

JavaScript is a versatile scripting language primarily used to add interactivity and dynamic behavior to web pages.

What’s the difference between var, let, and const?

  • var is global scope, generally used in ES5 and before.
  • const is block scoped and is not reassignable.
  • let is block scoped and IS reassignable.

What’s the difference between == and ===

== is loose equality. it Converts values to the same type before comparing them. so 5 & "5" are the same. === is strict and compares values without type conversion.

Explanation

What is null vs undefined?

  • undefined variable has been declared but doesnt have a value
  • Null means an empty value. It is empty or blank
Explanation

What are arrow functions and how are they different?

They are syntax sugar and can be more concise than regular functions

code snippet of an arrow functionExplanation

What are variables?

A variable is like a container that stores data, It lets you save information (like a number, text, object, etc.) and use it later in your program

Methods in Javascript

Wnat does Array.map() do?

The map() method creates a new array by applying a function to each element in the original array

What does Array.filter() do?

The filter() method creates a new array, including only the elements that pass the test implemented by the provided function

What is a Method?

A method is a function that is a property of an object. Essentially, they are used to manipulate objects.

Explanation

How is .forEach() different from .map()?

  • 1.Map returns a new array. Foreach returns undefined
  • 2.Map can be chained with other methods
  • 3.Slight performance based on computer speeds and data
Explanation

How is a method different from a regular function?

A regular function is a standalone block of code that you can define and call independently.A method is a function that's attached to an object and is called using that object.

What is the difference between .push() & .pop()?

.Push() adds to the end of the array and returns the new length. .pop() removes the last item in an array and returns the new length.

General Javascript Questions

What is the difference between a function declaration and a function expression?

  • A function declaration defines a named function using the function keyword. It is hoisted.
  • A function expression defines a function and assigns it to a variable. It can be anonymous or named, but it is not hoisted.
Explanation

What is the difference between synchronous and asynchronous code?

  • Synchronous: Blocks execution until it's done
  • Asynchronous: Allows other code to run while waiting

What is the spread operator (...) used for?

  • Expand arrays or objects
  • Clone or merge arrays/objects
  • Pass multiple arguments to a function
Explanation
Homepage