Onur Dayıbaşı
Jul 1 · 2 min read

Question: What is the value of foo?

var foo = 10 + '20';console.log(foo);   //Result '1020' because its string concat operation

Question: What will be the output of the code below?

console.log(0.1 + 0.2 == 0.3);console.log(result);  //Result false because float keep binary in mem so when convert 0.1 or 0.2 to binary its not same 0.1 0.10000000001 etc.

Question: How would you make this work?

add(2, 5); // 7
add(2)(5); // 7
const add=(a, b)=>{
if(a && b) return a+b;
else return buffAdd=(b)=>{return a+b}
};
console.log(add(2, 5));
console.log(add(2)(5));

Question: What value is returned from the following statement?

"i'm a lasagna hog".split("").reverse().join("");const stringOpsResult="i'm a lasagna hog".split("").reverse().join("");
console.log(stringOpsResult);
//goh angasal a m'i. how ? splits generates 17 char array all char reverse then the string generate

//if we split(" ") and join(" ") this time we generate 4 word array and we reverse word hog lasange a i'm

Question: What is the value of window.foo?

( window.foo || ( window.foo = "bar" ) );
console.log(window.go); //Result is 'bar' if we use && then second command not work so window.foo=undefined

Question: What is the outcome of the two alerts below?

var foo = "Hello"; (function() 
{var bar = " World"; alert(foo + bar);})(); //Alert=> Hello World
alert(foo + bar); // Reference Error bar is not defined

Question: What is the value of foo.length?


var foo = [];
foo.push(1);
foo.push(2);
console.log(foo.length); //Results is 2

Question: What is the value of foo.x?

var foo = {n: 1};
var bar = foo;
foo.x = foo = {n: 2}; //foo.x = (foo = {n:2}); => {n:1}.x = ( {n:1} = {n:2} ); R.H.S. foo={n:2}
console.log(foo.x); //Result undefined
console.log(foo); //Result {n:2}
console.log(bar); //Result {n:1, x: {n:2}}
Result = undefined

Question: What does the following code print?

console.log(‘one’);
setTimeout(function() {
console.log(‘two’);
}, 0);
Promise.resolve().then(function() {
console.log(‘three’);
})
console.log(‘four’);
//Result one, four , three, two its easy for one and four but theb why first three and then two prints.
//All of timeout and promise is async func..
//Answers is timeout in EventLoop Queue , promise process in JobQueue and JobQueue is high priority…

Question: What is the difference between these four promises?

//One level difficult..
//The answer https://gist.github.com/nolanlawson/940d1a390b2d9cf9483c

Promises answers

Frontend Development With JS

Frontend Development With Javascript

Onur Dayıbaşı

Written by

Senior Frontend Developer at Thundra

Frontend Development With JS

Frontend Development With Javascript

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade