From bef52459bdc313c909c738e75fe0295bf3d7e280 Mon Sep 17 00:00:00 2001 From: Prabhakar Kumar Bansal <32395636+PRABHAKAR9107@users.noreply.github.com> Date: Sat, 8 Oct 2022 20:33:08 +0530 Subject: [PATCH] Some output mistakes Hello Priya, I saw some output mistakes during solving problems. line no:- 140 and 141 output :-{} //There are only six falsely values in JavaScript: undefined, null, NaN, 0, "" (empty string), and false of course. {} is truthy value. line no:- 180 to 183 We can also achieve the result through the spread operator, but we can consider the above method as the best practice. line no:- 473 to 477 In line no 477 we are also invoking arrow fn as well .so, output is number --- 100Questions/100_JS_Que | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/100Questions/100_JS_Que b/100Questions/100_JS_Que index a318173..2420f45 100644 --- a/100Questions/100_JS_Que +++ b/100Questions/100_JS_Que @@ -138,7 +138,7 @@ console.log(name()); //Error: name is not a function //Explaination : Function we are calling but it's not present so it will an error. -------------------------------------------- const result = false || {} || 20 || null; -console.log(result); //20 +console.log(result); //{} //Explaination : OR operator will find first positive value. Null is a falsy value by default. {} is a positive value. It didn't reach till 20 and null. -------------------------------------------- const result = null || false || ''; @@ -181,7 +181,7 @@ function sumValues(x,y,z){ return x+y+z; } sumValues(...[2,3,4]) //how to call a function so that output will be 9 -//Explaination : we can't do like this sumValues(2,3,4). +//Explaination : we can't do like this sumValues(2,3,4). // we can also call through spread operator ---------------------------------------------------- const name = "priya is a girl."; console.log(typeof name); //string @@ -474,7 +474,7 @@ function sayHi(){ return ()=>0; } console.log(typeof sayHi()); //function -console.log(typeof sayHi()()); //function +console.log(typeof sayHi()()); //number //Explaination : sayHi will return anonymous arrow function/IIFE, where we didn't invole the arroe function so it will return function. ----------------------------------------------------------------------------- console.log(typeof typeof 1); //string