DEV Community

vidhya murali
vidhya murali

Posted on

JavaScript Interview Questions

Java vs JavaScript

  • Java - Java is a statically typed, object-oriented programming language for building platform-independent applications.
  • JavaScript - JavaScript is a dynamically typed scripting language primarily used for interactive web development.

Scripting vs Programming Language

All scripting languages are programming languages, but not all programming languages are scripting languages. The primary technical distinction lies in how the code is executed—scripting languages are traditionally interpreted line-by-line at runtime, while general programming languages are compiled into binary machine code before execution

Array vs Objects

  • In JavaScript, arrays and objects have specific behaviors, built-in methods, and performance characteristics that dictate how you use them.Technically, arrays in JavaScript are actually a special type of object under the hood, but they are treated differently in daily coding. Objects (Key-Value Pairs)Objects use curly braces {} and access data via text keys (properties) using dot notation or bracket notation.

Promise

  • In JavaScript, a Promise is an object representing the eventual completion (or failure) of an asynchronous operation and its resulting value. Think of it like a buzzer at a restaurant: you order your food (start an async task), they give you a buzzer (the Promise), and you can continue talking to friends while the food cooks. When the buzzer lights up, you get your meal (the value) or a notification that they ran out of ingredients (the error).

Asynchronous Functions

An asynchronous function is a special type of JavaScript function defined with the async keyword that always returns a Promise and allows you to use the await keyword inside it.They provide a clean, sequential syntax for handling asynchronous operations, completely eliminating the need for messy .then() and .catch() chains.

Top comments (0)