Top Tricky JavaScript Interview Questions and Answers

  Рет қаралды 82,950

techsith

techsith

Күн бұрын

Пікірлер: 203
@anand10parmar
@anand10parmar 5 жыл бұрын
The one you mentioned for sorting is not working. Instead of returning ab it should be a-b or b-a in the call back function. Thank you for this video :)
@workbutlive
@workbutlive 5 жыл бұрын
Thanks, I was reading the comments for this.
@abdelkrimhaddadi5098
@abdelkrimhaddadi5098 5 жыл бұрын
Yes, you are right, because the callback function does not return boolean value! It has to return an Integer value (negative, zero or positive). For example, if you want to sort a number's array, you have to write down the callback function something like that : [2, 3, 43, 467, 56, 8].sort((elt1, elt2) => {return elt1 < elt2 ? -1 : (elt1 === elt2 ? 0 : 1)}); // ascending way Output => [2, 3, 8, 43, 56, 467] [2, 3, 43, 467, 56, 8].sort((elt1, elt2) => {return elt1 < elt2 ? 1 : (elt1 === elt2 ? 0 : -1)}); // ascending way Output => [467, 56, 43, 8, 3, 2]
@atharvanaik2434
@atharvanaik2434 4 жыл бұрын
It works in Gecko...I mean firefox's engine...Doesn't work in V8...i.e. Chrome, Nodejs would give unexpected output
@bigtimecoder2588
@bigtimecoder2588 3 жыл бұрын
Also worth mentioning. You can turn it into a ternary statement using the ? : Syntax, like a < b ? 1 : -1 Then it will return the proper sorting (least to greatest). Or change the above to > sign for same thing but will sort greatest to least. If they are equal then not sure what will happen though because it should be 0 in the case.
@ayush7009
@ayush7009 3 жыл бұрын
try a-b instead of a>b
@karimullashaik1214
@karimullashaik1214 6 жыл бұрын
Thank you so much for making the videos and helping the web developers careers. For some reason, the sorting of integers with callback didn't work with a
@4ipon4ik
@4ipon4ik 2 жыл бұрын
I am too late with homework, but NaN === NaN is false because NaN is typeof Number which is an object (not primitive). When you compare objects in JavaScript, you are determining if 2 objects are the same instance of specified object type. So you are comparing 2 different instances of Number object. For example undefined === undefined is true, because undefined is primitive type (you are just comparing values). And seems like my answer is wrong 😅
@alreadytakenindeed
@alreadytakenindeed Жыл бұрын
It is right, good explanation!
@4ipon4ik
@4ipon4ik Жыл бұрын
@@alreadytakenindeed even if my explanation sounds like a true, you shouldn't believe. It was just my opinion.
@ashishprasad2949
@ashishprasad2949 Жыл бұрын
Well i guess u r half correct, NaN is non-primitive object and 2 non primitive objects arent equal to each other because they are stored at a different memory heap...
@inspektorkludge
@inspektorkludge 6 жыл бұрын
For the sorting one, the comparison is not working because the function looks for a number value, not a boolean :( x.sort((a,b) => (a-b)) works though! Thanks for this though and I love your videos
@2dabang
@2dabang 5 жыл бұрын
I also bumped into this issue. (a-b) worked but (a
@chunk1978
@chunk1978 5 жыл бұрын
Exactly, and for descending order you would write x.sort((a, b) => b - a);
@atharvanaik2434
@atharvanaik2434 4 жыл бұрын
@@2dabang V8 doesn't support that, I guess, because Node also doesn't support a > b
@ajaygaur3392
@ajaygaur3392 6 жыл бұрын
If an interviewer asks you these questions, just leave the interview because there are tonnes of things to ask about code management, design patterns and consideration of scalability.
@Techsithtube
@Techsithtube 6 жыл бұрын
Yes, I agree. but sometimes people ask such questions and its unfortunate.
@prakashsam4230
@prakashsam4230 6 жыл бұрын
Yes, interviewer ask me to solve sum(1)(2)(3) //ans =6.. im really confused after this ques they ask me easy ques but could not answer it because of 1st ques
@VishnuvardanRS
@VishnuvardanRS 6 жыл бұрын
var i = 0; function sum(n) { i+=n; return sum; } sum(1)(2)(3)(6); console.log(i); I learned from TechSith only. Function chaining.
@mostafashawki
@mostafashawki 6 жыл бұрын
Sure interviewer asks you these questions, it's really a great video.
@TheWesker1988
@TheWesker1988 6 жыл бұрын
Interviewers are asking these questions just to see how you could understand JS. It won't be major part of the interview and they expect you to answer them less than 5 min.
@owenwood14
@owenwood14 4 жыл бұрын
Just a note as a mathematician - 0/0 is undefined mathematically, rather than infinite (think: anything multiplied by 0 is 0, but anything divided by 0 is infinite, so 0/0 doesn't have any value). When we have i = MIN_VALUE, i*i is 0 because i*i is less than i, so js makes it zero (as appears to be the definition of MIN_VALUE). And then i/i is 1 not because i is small, but just because anything divided by itself is one (except 0/0).
@SonuKumar-gn1hm
@SonuKumar-gn1hm Жыл бұрын
The one you mentioned for sorting is not working. Instead of returning ab it should be a-b or b-a in the call back function.
@mendelson-dev
@mendelson-dev 5 жыл бұрын
it is worth mentioning that when we use "use strict" it will throw the error (example with IIFE)
@frontend-coder
@frontend-coder 6 жыл бұрын
NaN compared to anything is always false, even comparing to itself!
@Techsithtube
@Techsithtube 6 жыл бұрын
That is the right answer. :)
@gidmanone
@gidmanone 6 жыл бұрын
is there a point to memorizing this type of NaN trivial apart from this interviews. i mean one can always look it up in real life scenarios, no?
@chungching9253
@chungching9253 5 жыл бұрын
techsith hello sir .. can I have your email or contact number.. wanted to talk with you. Please let me know
@borschetsky
@borschetsky 5 жыл бұрын
But isNan(Nan) will be true; isNan('hello') will be true Number.isNan('hello;) will be false. JS is killing me)
@shubhamarora1441
@shubhamarora1441 3 жыл бұрын
Your videos are great. They are short but covers a lot. Keep doing the great work 👍🏻
@dantegreyson2014
@dantegreyson2014 6 жыл бұрын
Thanks for the Q&A!! Really love the videos. For the problem [1, 2, 3] + [4, 5, 6] how come the "[" and "]" were ignored but not the commas "," during concatenation?
@Techsithtube
@Techsithtube 6 жыл бұрын
yes because its JavaScript :) Basically it try to convert array to string.
@carefree_ladka
@carefree_ladka 2 жыл бұрын
When you said 0/0 is infinite, it's not true. It's always NaN in JavaScript. And it's not infinite in Mathematics either. Your videos are great source of learning. Thank you for making time and making these ones 🙂.
@MrAmarJK
@MrAmarJK 5 жыл бұрын
p=[12, 2, 3, 33]; p.sort((a,b)=> {return Number(a) - Number(b);})
@GabrielVasile
@GabrielVasile 5 жыл бұрын
Easier this way... p.sort((a,b)=> {return a - b;}) Minus sign implicitly coerce them to Number;
@sayedabdulkarim7086
@sayedabdulkarim7086 5 жыл бұрын
var arr = [2,3,42,4,5,4,5,6,7,2,3] , if we have an array like this we cannot get expected results with '' operator
@abdelkrimhaddadi5098
@abdelkrimhaddadi5098 5 жыл бұрын
Yes, you are right, because the callback function does not return boolean value! It has to return an Integer value (negative, zero or positive). For example, if you want to sort a number's array, you have to write down the callback function something like that : [2, 3, 43, 467, 56, 8].sort((elt1, elt2) => {return elt1 < elt2 ? -1 : (elt1 === elt2 ? 0 : 1)}); // ascending way Output => [2, 3, 8, 43, 56, 467] [2, 3, 43, 467, 56, 8].sort((elt1, elt2) => {return elt1 < elt2 ? 1 : (elt1 === elt2 ? 0 : -1)}); // ascending way Output => [467, 56, 43, 8, 3, 2]
@SameerUnt
@SameerUnt 5 жыл бұрын
2:31 index doesn’t mean to find the value. Its like find me the location of that value.
@GabrielVasile
@GabrielVasile 5 жыл бұрын
Another way of adding two arrays together and display them as a string is this: [1,2,3].concat([4,5,6]).toString()
@deepakgour2372
@deepakgour2372 4 жыл бұрын
console.log(55555555555555555555555) I never seen this type of questions. How do you find such a type of questions like this? This is awesome.🙂👍🏻
@ankush3707
@ankush3707 3 жыл бұрын
i was doing a project work and came across this issue related to 18 digit number
@osamatalaat5354
@osamatalaat5354 6 жыл бұрын
Thank you so much We wanna a separate Playlist to all of the Tricky Javascript interview questions videos
@jaymartinez311
@jaymartinez311 2 жыл бұрын
You have to use the diffing of the comparison for the sort method. It won't work if you don't. console.log('answer:', arrayList.sort((a, b) => { return a - b; }));
@Roysameer3986
@Roysameer3986 4 жыл бұрын
Use Number.isNaN(NaN) to compare it will return true
@DevDoodle5555
@DevDoodle5555 Жыл бұрын
These are JS interview questions straight out of hell 🔥 😂 Thank you so much for your super insightful and quick videos! I love them
@HaraHaraMahadev777
@HaraHaraMahadev777 5 жыл бұрын
Sorting is not working, the return must be a-b for Ascending and b-a for descending order console.log(a.sort((a,b)=>{return a-b})); // Asc console.log(a.sort((a,b)=>{return b-a})); // Desc
@hatrick3117
@hatrick3117 6 жыл бұрын
Gonna answer honest for my thought on NaN === NaN... The result of it must be false (otherwise there is no point in question) :) I read about it, I gues it was in "You think you know JS", I think its just made that way couse NaN could be an expression for a lot of things, thats all I have :D
@rishanthkanakadri414
@rishanthkanakadri414 6 жыл бұрын
NaN compared to anything is always false.However, Here comes the interesting stuff (typeof null is an Object and type of Object is also Object. When you do a "==" with both of them, it will return you a false.
@Techsithtube
@Techsithtube 6 жыл бұрын
Correct!
@aniketverma4434
@aniketverma4434 2 жыл бұрын
Love the way you explain ❤
@Amit-oz9vr
@Amit-oz9vr Жыл бұрын
If Type(x) is Number, then If x is NaN, return false. If y is NaN, return false.
@arshamazami159
@arshamazami159 4 жыл бұрын
False NaN is short for not a number and I think the reason NaN === NaN is false is it might be different opertaions like 2/0 or √-7.both of them are NaN but the opertaion numbers are different
@naveenreddydepa8324
@naveenreddydepa8324 6 жыл бұрын
I feel much fun, enthusiastic while attempting these interview questions.Awesome stuff
@Techsithtube
@Techsithtube 6 жыл бұрын
I am glad its fun for you, I will make some more. :)
@nistala8984
@nistala8984 2 жыл бұрын
NaN is not a specific value it is just saying that that particular value is not a number hence the value of NaN need not to be same so it returns false if compare NaN with NaN using == or ===
@marcmoo9130
@marcmoo9130 6 жыл бұрын
null===null give you true,NaN==NaN give false
@Techsithtube
@Techsithtube 6 жыл бұрын
You got it. Thanks for the response.
@devolee8302
@devolee8302 6 жыл бұрын
I really enjoy these series. Thanks you sir!
@Harshavardhan-gd4eu
@Harshavardhan-gd4eu 6 жыл бұрын
Great Video as always :) Thanks for making JavaScript so easier to learn :) .
@Techsithtube
@Techsithtube 6 жыл бұрын
Thanks for watching harsh!
@BenSmith-et9fv
@BenSmith-et9fv 6 жыл бұрын
I like that interview series. thanks!
@richardwatts20
@richardwatts20 4 жыл бұрын
This is interesting, but as someone has already said in the comments, if I was asked some of these questions in an interview I would walk out the door...
@asingb
@asingb 6 жыл бұрын
👍 cool experiments with js. thank you sir.
@kamaboko1
@kamaboko1 6 жыл бұрын
I enjoy these JS questions videos.
@sureshmg6786
@sureshmg6786 5 жыл бұрын
Very tricky and helpful!
@greatgoblinonizuka12
@greatgoblinonizuka12 6 жыл бұрын
i love your accent it's very clear!
@Techsithtube
@Techsithtube 6 жыл бұрын
Thank you :)
@kanishmishra4716
@kanishmishra4716 5 жыл бұрын
sorting is not working using arr.sort((a,b)=>{return a
@abdelkrimhaddadi5098
@abdelkrimhaddadi5098 5 жыл бұрын
Yes, you are right, because the callback function does not return boolean value! It has to return an Integer value (negative, zero or positive). For example, if you want to sort a number's array, you have to write down the callback function something like that : [2, 3, 43, 467, 56, 8].sort((elt1, elt2) => {return elt1 < elt2 ? -1 : (elt1 === elt2 ? 0 : 1)}); // ascending way Output => [2, 3, 8, 43, 56, 467] [2, 3, 43, 467, 56, 8].sort((elt1, elt2) => {return elt1 < elt2 ? 1 : (elt1 === elt2 ? 0 : -1)}); // ascending way Output => [467, 56, 43, 8, 3, 2]
@prabhukadode723
@prabhukadode723 6 жыл бұрын
sir , i have one question. Actually i was asked this question in interview. the question is about converting normal javascrpt function to call back function... so question goes like this,... function aa(){ return 1; } var res = aa(); so they wanted me to convert above function into call back function.. how to do sir ? plz help
@flysports3856
@flysports3856 6 жыл бұрын
const aa = () => 1; It has to be explicitly declared to use as a callback.
@gagandeep531
@gagandeep531 5 жыл бұрын
@@flysports3856 var res= aa; function test(cb){ if(typeof cb === 'function'){ let output = cb(); console.log(output); } } test(bb); This might help
@swetharedddysh
@swetharedddysh 3 жыл бұрын
I think we can do like this function aa(b) { console.log('sum is : ' + b); } function bb(a, b, cc) { let x = a + b; cc(x); } bb(1, 2, aa);
@prabhukadode723
@prabhukadode723 2 жыл бұрын
@@swetharedddysh Hi thank you so much . Your solution works well.
@TheRaghavboyz
@TheRaghavboyz 6 жыл бұрын
Love your videos man.
@YambeeStarVideo
@YambeeStarVideo 5 жыл бұрын
8:44 - wrong. MAX_VALUE multiplies to Infinity, not 0
@dumi9838
@dumi9838 5 жыл бұрын
05:25 I don't seem to get it to work by using return a > b. Weird thing is that if I return a - b then it works properly. Am I doing something wrong? Thank you in advance. const arr = [1, 2, 15, 30, 5, 45, 7]; console.log(arr.sort((a, b) => { return a - b; }));
@Techsithtube
@Techsithtube 5 жыл бұрын
That is a correct syntax for the callback. a-b is correct.
@dumi9838
@dumi9838 5 жыл бұрын
​@@Techsithtube I made a fiddle in which I console log the example you used in this video that isn't working for me. jsfiddle.net/2yr69pn7/ I'm really confused why the minus sign is doing the sort correctly but the less/greater than sign isn't. Thank you for the instant reply! That caught me off guard haha :D
@Techsithtube
@Techsithtube 5 жыл бұрын
Its basically how the sort is implemented in javaScript other languages a>b makes sense but javaScript decided to go this way.
@ErnestGWilsonII
@ErnestGWilsonII 6 жыл бұрын
First of all let me say thumbs up and I am already subscribed of course with notifications turned on! Thanks for taking the time to make another educational and fun video and share it with all of us! I am on my phone so I cannot test your final homework, it feels like it should be a truthy question and normally I would say in this case it should evaluate to true, however since you are trying to trick us, somehow I bet it is false? Is something weird with NaN?
@Techsithtube
@Techsithtube 6 жыл бұрын
You guessed it right. it is false . that is becase NaN compares unequal (via ==, !=, ===, and !==) to any other value -- including to another NaN value.
@ErnestGWilsonII
@ErnestGWilsonII 6 жыл бұрын
techsith this was fun, you should consider putting out one trick question or brain teaser every week
@erez7020
@erez7020 5 жыл бұрын
If a programmer asks this "trick question" in an interview, I get up and leave. All to the fact that NO ONE will dare write this type of shit and commit this code, it's unreadable, unrelated and confusing, if you would like to return (-1) from your array, there are a myriad of SIMPLE AND READABLE ways to do it. The only thing I could think he's trying to gain out of this is him trying to show me that he knows how to be a good QA, nothing more.
@Alexanderthenotsobad
@Alexanderthenotsobad 2 жыл бұрын
Agreed... The first few questions were valid, then he went off the rails.... GL2U
@treyrader
@treyrader 2 жыл бұрын
It’s just a question so to challenge your understand of how es6 gets compiled. It’s one thing to “know that” the behavior of an operation returns an output, but it’s best practice to “know how”, epistemologically speaking. These challenges are just a glimpse into how powerful js can get. Sure, you will not see code written as such because it doesn’t follow the object-oriented principal of being semantic as possible.
@Alexanderthenotsobad
@Alexanderthenotsobad 2 жыл бұрын
@@treyrader OK, you seem like quite a learned individual, and I think I understand your point about OO semantics, but I would argue that JavaScript's OO epistemology -- the actual overarching theme of this video -- is actually "synthetical sugar." I believe you may be referring to Typescript, which as you may know, is a superset of JS. Please correct me if I'm mistaken.
@treyrader
@treyrader 2 жыл бұрын
@@Alexanderthenotsobad Hey man, sorry for the late reply as I am just now seeing the notification. I think you are correct that perhaps I was referring to typescript, albeit inadvertently. In truth, my knowledge of web concepts and of JS is, comparativelys peaking, pretty far from vast. This explains why I am on youtube watching tutorials on it as well as why I had to look up the concept of "Typescript.". All that I was trying to express though in my prev comment is that the questions prompted in this mock interview are just a tool for the person conducting the interveiw to assess your ability to problem solve. It makes sense to me that the questions in the end of the interview would seem almost irrevelant and entirely unorthodox to the convention of standard coding so to ensure that they aren't rotely memorized. Were the interviewee to get these correct, surely it'll exceed the expectations of the interveiw and thus ensure that he or she is a spectacular candidate. Cheers!
@shadabanwar2101
@shadabanwar2101 5 жыл бұрын
I don't understand why I have to write a callback to sort! I already provided array of integers! Totally unexpected!
@swapnilpakolu4395
@swapnilpakolu4395 5 жыл бұрын
Great 👍
@ascukins
@ascukins 6 жыл бұрын
Thanks ) Love your videos!
@kamal-ahmed
@kamal-ahmed 6 жыл бұрын
Nice video. Thanks for your hard work and time.
@nofavors
@nofavors 6 жыл бұрын
more homeworks pls.. specially coding problems and interview tasks
@sergeymigel4680
@sergeymigel4680 4 жыл бұрын
Thank you, Man!
@karthikmatreddy1236
@karthikmatreddy1236 6 жыл бұрын
=== compares value and data type right (value same)(type of nan is number so data type also same)value same data type same it will returns true right
@Techsithtube
@Techsithtube 6 жыл бұрын
Nan is an exception, you will get false
@karthikmatreddy1236
@karthikmatreddy1236 6 жыл бұрын
Thank you
@samirmahmudlu
@samirmahmudlu 4 жыл бұрын
Thanks
@Techsithtube
@Techsithtube 4 жыл бұрын
Welcome
@mrkaspr
@mrkaspr 4 жыл бұрын
whats the reason ary.sort() treated the array as a string?
@TheRaghavboyz
@TheRaghavboyz 6 жыл бұрын
Here we go again.
@pravini2116
@pravini2116 4 жыл бұрын
console.log(NaN === NaN);it returns false,beacause we dont know what exactly number we are doing operations.:-)
@blu8762
@blu8762 6 жыл бұрын
hello sir can you tell me what should i learn i mean the things i really need so i can move on to js frameworks ? i would love if you make some simple realtime projects using js and thanks for the awesome videos !
@Techsithtube
@Techsithtube 6 жыл бұрын
learn latest version of JavaScript don't try to learn old deprecated stuff and then pick a framework like react.
@sreenathreddy1239
@sreenathreddy1239 5 жыл бұрын
I loved it, Can i have quations like this of angularJS 1.x as well?
@NaamJapMantra
@NaamJapMantra 5 жыл бұрын
very nice...
@venkateshvenkat2302
@venkateshvenkat2302 5 жыл бұрын
Thank you so much sir
@Techsithtube
@Techsithtube 5 жыл бұрын
Thanks for watching venkatesh.
@scorpio9ification
@scorpio9ification 6 жыл бұрын
Liked before watching crew
@Techsithtube
@Techsithtube 6 жыл бұрын
Thanks for the like:)
@LawZist
@LawZist 6 жыл бұрын
You are the best!
@anupamark4658
@anupamark4658 5 жыл бұрын
In the video 12.17, if b is a global variable. Why it didn't print at first time. Please reply back
@kannu755
@kannu755 5 жыл бұрын
Because program stopped running after it gets an error from console.log(a)
@anupamark4658
@anupamark4658 5 жыл бұрын
@@kannu755 Thank you ...
@AlwaysBeTactful
@AlwaysBeTactful 2 жыл бұрын
write code to display even number s from 20 to zero using the Do-While loop Javascript This is my code its not correct, I need some help please var i = 0; var n = Number(window.prompt("Enter any number : ")); do{ i--; document.write("Number is = " + i + ""); }while(i
@anversadutt
@anversadutt 6 жыл бұрын
NaN === NaN; // false because NaN, and only NaN, will compare unequal to itself.
@jainshilpi3
@jainshilpi3 6 жыл бұрын
great video sir
@Chillwire-c2b
@Chillwire-c2b 3 жыл бұрын
sir ascending & descending order code is not working it gives same array
@priyanshupatel2464
@priyanshupatel2464 3 жыл бұрын
ary.sort((a,b)=>aa-b)
@Techsithtube
@Techsithtube 3 жыл бұрын
For numbers you need to use a-b
@osamatalaat5354
@osamatalaat5354 6 жыл бұрын
Please you said in minute 03:00 that you will provide a link of negative index video in Javascript so where is the link of the negative index in Javascript video?!
@saradatadepalli4226
@saradatadepalli4226 6 жыл бұрын
cont x=[1,2,3]; x.indexOf[10000] will be -1 as you said but when I tried doing that it's getting undefined.
@Techsithtube
@Techsithtube 6 жыл бұрын
If you watch the video there is another line which is missing here. if you add that you will get expected result.
@jimeejain7986
@jimeejain7986 6 жыл бұрын
X.indexOf(10000). Wrong brackets
@brandonrobinson8452
@brandonrobinson8452 5 жыл бұрын
I couldnt find the tutorial on negative indexes. Could someone please point me to it?
@darrylbrian
@darrylbrian 4 жыл бұрын
Here it is: kzbin.info/www/bejne/pneolXmcd5eYrac
@jitendrajahagirdar2629
@jitendrajahagirdar2629 6 жыл бұрын
Hello sir In interview i was get ask for the below question and expected result part of array convert string . Question var sampleArry = [1,2,3 {a:4, 5} 6, 7 , 8, [9,10] ] Expected [1,2,3,4,5,6,7,8,9,10] Can you please explain how to fix it. In question of array there is tricky part of object in side of array which is not canvter as a string. Kindly reply
@licmi
@licmi 6 жыл бұрын
What abou this ? var sampleArry = [1, 2, 3, { a: 4, b: 5 }, 6, 7, 8, [9, 10]]; sampleArry[7].map(res => { sampleArry.push(res); }); sampleArry.splice(7, 1); let obj = Object.values(sampleArry[3]); sampleArry.splice(3, 1); sampleArry.push(...obj); console.log(sampleArry.sort((a, b) => a - b));
@flysports3856
@flysports3856 6 жыл бұрын
const arr = [[0, 1], 33, {a:4}, [2, 3], [4, 5]]; const newArr = arr.reduce((acc, b) => { if(Object.values(b).length) b = Object.values(b); return acc.concat(b);; }, []); console.log(newArr);
@andrewdeiak6871
@andrewdeiak6871 3 жыл бұрын
Nice!
@osamatalaat5354
@osamatalaat5354 6 жыл бұрын
Thank you so much ❤❤❤ But Where is the link of the negative index video?!
@darrylbrian
@darrylbrian 4 жыл бұрын
Here it is: kzbin.info/www/bejne/pneolXmcd5eYrac
@mohaklondhe3020
@mohaklondhe3020 3 жыл бұрын
why maxvalue - maxvalue gives maxvalue, and not zero
@beaverjoe9171
@beaverjoe9171 6 жыл бұрын
video is great but HR would not ask so many tricky and meaningless question for one student. Such question based on concepts but far away from the real world
@venkykp174
@venkykp174 3 жыл бұрын
Super
@abhitmallik3528
@abhitmallik3528 3 жыл бұрын
Hello sir, The last question (NaN ===NaN) will give false
@petrzavadskii7179
@petrzavadskii7179 2 жыл бұрын
Last statement is results by false thus one NaN not equal to another NaN
@SmartWizzard
@SmartWizzard 2 жыл бұрын
Hi, for me it's showing 5e-324 when I do Number.MIN_VAL / 1
@4ipon4ik
@4ipon4ik 2 жыл бұрын
There was i / i not i / 1.
@meetshujah
@meetshujah 6 жыл бұрын
where is the link of minus index tutorial sir?
@Techsithtube
@Techsithtube 6 жыл бұрын
I was going to upload that video with this video but go busy. I will upload this weekend.
@mahendraprajapati3828
@mahendraprajapati3828 6 жыл бұрын
Hello Sir, i try same but i get wrong result ... const ary = [1,21,334,44,2,3,4,5,667,7,8,80,55]; alert(ary.sort()); alert(ary.sort((a,b) => { return a < b; })) alert(ary.sort((a,b) => { return a > b; })) what's wrong here...
@Techsithtube
@Techsithtube 6 жыл бұрын
what did you get?
@minhaz33
@minhaz33 5 жыл бұрын
Should be return a - b
@lalitkumar50678
@lalitkumar50678 3 жыл бұрын
Thanks, Answer is last question is true
@susmitashinkar9095
@susmitashinkar9095 4 жыл бұрын
The one you mentioned for sorting is not working
@Techsithtube
@Techsithtube 4 жыл бұрын
which particular one?
@RishiRaj95
@RishiRaj95 5 жыл бұрын
Note:- 0/0 is NaN 1/0 is Infinite
@chandrasekharrachapudi5758
@chandrasekharrachapudi5758 2 жыл бұрын
This is an Interview question. Can anyone explain the answer why when using for loop inside "var" 10 times iterating and showing undefined and when using "let" for loop inside getting the 1,2,3,..., 10. const a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; for (var i = 0; i < 10; i++) { setTimeout(() => console.log(a[i]), 1000); }
@Bakuta1103
@Bakuta1103 6 жыл бұрын
As a primarily c++ programmer, I am thoroughly confused :)
@Techsithtube
@Techsithtube 6 жыл бұрын
JS is confusing for programmes from other languages. First of all its nonblocking and second of all it has lots of weird things that you can still use it but you shouldn't. I would suggest to learn only latest JavaScript .
@johnnichols6325
@johnnichols6325 5 жыл бұрын
NAN === NAN returns false
@akab211
@akab211 6 жыл бұрын
Javascript is awesome!
@Techsithtube
@Techsithtube 6 жыл бұрын
indeed :)
@ManOnHorizon
@ManOnHorizon 6 жыл бұрын
11:05 - the weirdest part is if you console.log 17 fives it will return 55555555555555550. Shouldn't it have "..60" on the right? And console.log(44444444444444444); gives us this: 44444444444444450. Doesn't make any sense =)
@Techsithtube
@Techsithtube 6 жыл бұрын
As i said in the video after 16 numbers its all wierdness so you should not have integers that are longer than that.
@abhijeetsoni1978
@abhijeetsoni1978 6 жыл бұрын
techsith, I am still having doubt. Why it wasn't like 55555555555555560 with 5's similar to 44444444444444450 with 4's. I know, after 16 digits, it's all absurd but with others, we see that 16th digit increments and further digits truncates to 0s. Please clear me also on this. Anyways, I liked this video a lot. Keep going!
@Daniel_WR_Hart
@Daniel_WR_Hart 4 жыл бұрын
8:55, but Infinity != 0
@spacewad8745
@spacewad8745 6 жыл бұрын
I am really early I deserve love... Jokes aside, great content as usual!
@Techsithtube
@Techsithtube 6 жыл бұрын
Thanks for the first comment:)
@syedfaizan92
@syedfaizan92 6 жыл бұрын
11:53 how did the '6' come in?
@Techsithtube
@Techsithtube 6 жыл бұрын
Because it truncates.
@bhavleensingh6929
@bhavleensingh6929 4 жыл бұрын
hey! why are checking comments
@10my_rocks5
@10my_rocks5 6 жыл бұрын
Hi, Could you tell me Y this result is coming in my console? var i = Number.MIN_VALUE; console.log(i); console.log(i+i); console.log(i-i); console.log(i*i); console.log(i/i); VM173:2 5e-324 VM173:3 1e-323 VM173:4 0 VM173:5 0 VM173:6 1
@Techsithtube
@Techsithtube 6 жыл бұрын
THere is a MIN_VALUE in javaScript that is the smallest possible number. and adding one to it changes that number slightly. removing from the smallest number should make it a 0 same with multiplication. however, dividing the same number should give you one.
@abhishekkumargupta763
@abhishekkumargupta763 5 жыл бұрын
Output for last will be false,
@bapinmalakar3846
@bapinmalakar3846 6 жыл бұрын
Nan is also Nan so return false
@andrerothweiler9191
@andrerothweiler9191 6 жыл бұрын
I feel like I'm applying to be a Mathematician and not a Developer lol
@Techsithtube
@Techsithtube 6 жыл бұрын
Lol. Math is very important to pass as an engineer.
@andrerothweiler9191
@andrerothweiler9191 6 жыл бұрын
hmm, I think logic is more important but I can be wrong, good video btw. made a lots of people salty XD
@yongkiamirson2376
@yongkiamirson2376 3 жыл бұрын
IQ I Q......
@jakubmaximilian1419
@jakubmaximilian1419 Жыл бұрын
the last question should be printed false
Tricky JavaScript interview questions and answers
21:01
techsith
Рет қаралды 133 М.
How To Choose Mac N Cheese Date Night.. 🧀
00:58
Jojo Sim
Рет қаралды 64 МЛН
top 10 JavaScript tricks
17:18
techsith
Рет қаралды 19 М.
Answering tricky JavaScript interview questions
35:16
freeCodeCamp.org
Рет қаралды 68 М.
Tricky JavaScript Interview Questions and Answers
16:35
techsith
Рет қаралды 457 М.
Solving Output Based JavaScript Interview Questions
28:17
Devtools Tech
Рет қаралды 4,1 М.
Mock Technical Interview - Javascript Developer Entry Level
1:36:22
Tech with Nader
Рет қаралды 505 М.
Top 5 JavaScript Interview Questions with Answers!
29:33
ProCodrr
Рет қаралды 15 М.
Async Await JavaScript ES7
26:39
techsith
Рет қаралды 120 М.