Thursday, December 28, 2023

JavaScript interview questions and answers

 1. What is JavaScript?

JavaScript is a dynamic programming language that's used for web development, web applications, game development, and lots more. It allows to implementation of dynamic features on web pages that cannot be done with only HTML and CSS.

or

JavaScript is a prototype-based, multi-paradigm, single-threaded, dynamic language, that supports various types of programming styles such as object-oriented, imperative, and functional programming.

2. What are the data types in JavaScript?

Primitive Data Types:
Number:
Represents numeric values.
Example: let num = 42;

String:
Represents a sequence of characters.
Example: let str = 'Hello, World!';

Boolean:
Represents a logical value (true or false).
Example: let isTrue = true;

Undefined:
Represents a variable that has been declared but not assigned a value.
Example: let undefinedVar;

Null:
Represents the intentional absence of any object value.
Example: let nullVar = null;

Symbol (introduced in ECMAScript 6):
Represents a unique identifier.
Example: let sym = Symbol('unique');

BigInt (introduced in ECMAScript 2020):
Represents integers of arbitrary precision.
Example: let bigIntVar = 9007199254740991n;

Non-Primitive (Object) Data Types:
Object:
Represents a collection of key-value pairs.
Example: let obj = { key: 'value' };

Array:
Represents an ordered list of values.
Example: let arr = [1, 2, 3];

Function:
Represents a reusable block of code.
Example: function sayHello() { console.log('Hello!'); }

4. What is the DOM in JavaScript?

The Document Object Model (DOM) is a programming interface that represents the structure of HTML and XML documents. It allows JavaScript to access and manipulate


0 comments:

Post a Comment