Posts

Showing posts with the label Java Interview Questions

Javascript interview questions and answers with code

Image
To start a series for the JavaScript interview questions which may help junior to mid level developers. Common JavaScript interview questions with examples. 1. What is let and const in JavaScript? »  Let and const are block-scoped declarations in JavaScript, used to declare variables. let allows you to reassign the value of the variable, while const creates a read-only reference to a value. Example: let message = "Hello, World!"; message = "Hello, JavaScript!"; console.log(message); // Output: "Hello, JavaScript!" const PI = 3.14; PI = 3.14159; // TypeError: Assignment to constant variable. 2. What is arrow function in JavaScript? »   Arrow functions are a shorthand for anonymous functions in JavaScript. They are also known as “fat arrow” functions. Example: let add = (a, b) => a + b; console.log(add(1, 2)); // Output: 3 let numbers = [1, 2, 3, 4, 5]; let doubledNumbers = numbers.map(num => num * 2); console.log(doubledNumbers); // Output: [2, 4, 6,