var london = moment.tz(‘2021–10–08 11:14:23’, ‘Europe/London’);

console.log(london.format(‘MMMM Do YYYY, h:mm:ss a’));

var india = london.clone().tz(“Asia/Kolkata”);

console.log(india.format(‘MMMM Do YYYY, h:mm:ss a’));

var a = moment.tz(‘2021–10–08 11:14:23’, ‘Europe/London’).clone().tz(“Asia/Kolkata”).format(‘MMMM Do YYYY, h:mm:ss a’)

console.log(a);

let p= [‘a’,’a’, ‘g’, ‘f’, ‘b’,’z’,’y’,’c’,’t’ ,’s’,’x’,’x’,’n’];

var output =[],match=false;

for(var a =0;a < p.length;a++ ){
match=false;

for(var b=0; b<output.length ;b++){

if(output[b]===p[a]){
match=true;
}
}

if(!match){
output.push(p[a])
}

}

console.log(output)
console.log(“a”<”b”)

function getSort (x){

for(var b=1; b<x.length ;b++){
if(x[b-1]<x[b]){

}else{
let k = x[b];
x[b]=x[b-1]
x[b-1]=k
x= getSort (x)

}

}
return x
}
console.log(getSort(output))

Closure means that an inner function always has access to the vars and parameters of its outer function, even after the outer function has returned.

function OuterFunction() {

var outerVariable = 1;

function InnerFunction() {
alert(outerVariable);
}

InnerFunction();
}

JavaScript Hoisting refers to the process whereby the interpreter allocates memory for variable and function declarations prior to execution of the code. Declarations that are made using var are initialized with a default value of undefined. Declarations made using let and const are not initialized as part of hoisting.

What are promises?

A Promise is an object, representing the eventual completion or failure of an asynchronous operation.

why?

createAudioFileAsync(audioSettings).then(successCallback, failureCallback);

One of the great things about using promises is chaining.

  • Multiple callbacks may be added by calling then() several times. They will be invoked one after another, in the order in which they were inserted.

Promise.all() and Promise.race() are two composition tools for running asynchronous operations in parallel.

Promise.all([func1(), func2(), func3()])
.then(([result1, result2, result3]) => { /* use result1, result2 and result3 */ });

const promise = new Promise(function(resolve, reject) {
console.log(“Promise callback”);
resolve();
}).then(function(result) {
console.log(“Promise callback (.then)”);
});

setTimeout(function() {
console.log(“event-loop cycle: Promise (fulfilled)”, promise)
}, 0);

console.log(“Promise (pending)”, promise);

output will be

“Promise callback”
“Promise (pending)”
[object Promise] { … }
“Promise callback (.then)”
“event-loop cycle: Promise (fulfilled)”
[object Promise] { … }

Arrow function expressions

An arrow function expression is a compact alternative to a traditional function expression, but is limited and can’t be used in all situations.

Differences & Limitations:

Declarative programming is a programming paradigm … that expresses the logic of a computation without describing its control flow.
Imperative programming is a programming paradigm that uses statements that change a program’s state.

Declarative Programming is like asking your friend to fix your car. You don’t care how to fix it, that’s up to her.

Imperative Programming is like your friend calling your father that tells her how to fix your car step by step.

Imperative code instructs JavaScript on how it should perform each step. With declarative code, we tell JavaScript what we want to be done, and let JavaScript take care of performing the steps.

function checkPalindrome(i){

let sum=0,r=0,n=i;

while(i>0){
r=i%10;
sum=sum*10+(r);

i=parseInt(i/10)
console.log(sum,r,i)
}
console.log(n,”===”,sum)
if(n===sum){
return “Palindrome number “
}else{
return “not Palindrome number “
}
}

// console.log(checkArmstrongNumber(407))

console.log(checkPalindrome(121))