1. Asynchronous in JavaScript?
JavaScript that allows your code to run in the background without blocking the execution
of other code.
Types of asynchronous in JavaScript: HTTP Request, callback functions, promises, and
async-await
Example
2. let vs var
var, const and let are the keywords that can be used to declare the variables in JavaScript.
var keyword is globally and functionally scoped and it can be re-assigned
let keyword is functional and block scope and can also be re-assigned
const keyword is functional and block scope but it cannot be re-assigned
3. Callback function
A callback is a function that will be executed after another function gets executed.
function square(number){
console.log(number*number);}
function mainFunction(callback){
const number = 8;
callback(number);}
4. What is = and == and ===?
=: assign the values to a variable in JS.
==: used to compare two variables irrespective of the data type.
===:it will check data type and compare two variables.
5. Cookies, local storage, session storage?
Cookies: Files created by websites you visit.
Local Storage: Web application store the data locally within the user’s browser.
Session Storage: Data is lost when the browser tab is closed.
6. Validation in JavaScript & regex functions?
The process of ensuring that user input is clean, correct and useful.
Server-side Validation
Client-side Validation
Real-time Validation
25.
const calculator = {
value: 0,
add(...args) {
this.value += args.reduce((a, b) => a + b, 0);
return this;
}, subtract(...args) {
this.value -= args.reduce((a, b) => a + b, 0);
return this;
}, multiply(...args) {
this.value *= args.reduce((a, b) => a * b, 1);
return this;
}, divide(...args) {
this.value /= args.reduce((a, b) => a * b, 1);
return this;
}
};
const result = calculator.add(10, 20).multiply(2).divide(3).add(20, 40).multiply(10).value;
console.log(result); // Output: 4400
1. Spread operator?
allows us to quickly copy all or part of an existing array or object into another array or
object.
Array length--length of array
Array toString()--array to string
Array pop()--remove last element of array
Array shift()--remove first element of array
Array push()--add element to end of array
Array unshift()--add element to start of array
Array join()--add array elements as a string
Array delete()--delete element of array with index value
Array concat()--combain array elements
Array flat()--concatenates sub-array elements
Array splice()--remove the element of array by using index value
Array slice()--between array methods to delete elements