Тёмный

Top Tricky JavaScript Interview Questions and Answers 

techsith
Подписаться 147 тыс.
Просмотров 83 тыс.
50% 1

Cracking JavaScript coding Interview by learning difficult JavaScript interview Questions. commonly Asked JavaScript Interview Questions.
Please be my patreons on patreaon
* / techsith
Follow me for technology updates
* / techsith
* / techsith1
Help me translate this video.
* www.youtube.com...
Note: use translate.goog... to translate this video to your language. Let me know once you do that so i can give you credit. Thank you in advance.

Опубликовано:

 

26 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 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
@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...
@karimullashaik1214
@karimullashaik1214 5 лет назад
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
@inspektorkludge
@inspektorkludge 5 лет назад
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.
@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)
@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 4 года назад
it is worth mentioning that when we use "use strict" it will throw the error (example with IIFE)
@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).
@shubhamarora1441
@shubhamarora1441 3 года назад
Your videos are great. They are short but covers a lot. Keep doing the great work 👍🏻
@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]
@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
@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;
@osamatalaat5354
@osamatalaat5354 6 лет назад
Thank you so much We wanna a separate Playlist to all of the Tricky Javascript interview questions videos
@jaymartinez311
@jaymartinez311 Год назад
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; }));
@SameerUnt
@SameerUnt 5 лет назад
2:31 index doesn’t mean to find the value. Its like find me the location of that value.
@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 🙂.
@Roysameer3986
@Roysameer3986 4 года назад
Use Number.isNaN(NaN) to compare it will return true
@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 ===
@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
@Harshavardhan-gd4eu
@Harshavardhan-gd4eu 6 лет назад
Great Video as always :) Thanks for making JavaScript so easier to learn :) .
@Techsithtube
@Techsithtube 6 лет назад
Thanks for watching harsh!
@Amit-oz9vr
@Amit-oz9vr Год назад
If Type(x) is Number, then If x is NaN, return false. If y is NaN, return false.
@asingb
@asingb 6 лет назад
👍 cool experiments with js. thank you sir.
@aniketverma4434
@aniketverma4434 2 года назад
Love the way you explain ❤
@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. :)
@kamaboko1
@kamaboko1 6 лет назад
I enjoy these JS questions videos.
@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
@BenSmith-et9fv
@BenSmith-et9fv 6 лет назад
I like that interview series. thanks!
@ascukins
@ascukins 6 лет назад
Thanks ) Love your videos!
@YambeeStarVideo
@YambeeStarVideo 5 лет назад
8:44 - wrong. MAX_VALUE multiplies to Infinity, not 0
@sureshmg6786
@sureshmg6786 4 года назад
Very tricky and helpful!
@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!
@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]
@TheRaghavboyz
@TheRaghavboyz 6 лет назад
Love your videos man.
@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
@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!
@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
@greatgoblinonizuka12
@greatgoblinonizuka12 6 лет назад
i love your accent it's very clear!
@Techsithtube
@Techsithtube 6 лет назад
Thank you :)
@marcmoo9130
@marcmoo9130 5 лет назад
null===null give you true,NaN==NaN give false
@Techsithtube
@Techsithtube 5 лет назад
You got it. Thanks for the response.
@scorpio9ification
@scorpio9ification 6 лет назад
Liked before watching crew
@Techsithtube
@Techsithtube 6 лет назад
Thanks for the like:)
@sergeymigel4680
@sergeymigel4680 4 года назад
Thank you, Man!
@swapnilpakolu4395
@swapnilpakolu4395 5 лет назад
Great 👍
@pravini2116
@pravini2116 3 года назад
console.log(NaN === NaN);it returns false,beacause we dont know what exactly number we are doing operations.:-)
@sreenathreddy1239
@sreenathreddy1239 5 лет назад
I loved it, Can i have quations like this of angularJS 1.x as well?
@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...
@venkateshvenkat2302
@venkateshvenkat2302 5 лет назад
Thank you so much sir
@Techsithtube
@Techsithtube 5 лет назад
Thanks for watching venkatesh.
@petrzavadskii7179
@petrzavadskii7179 2 года назад
Last statement is results by false thus one NaN not equal to another NaN
@mohaklondhe3020
@mohaklondhe3020 3 года назад
why maxvalue - maxvalue gives maxvalue, and not zero
@shadabanwar2101
@shadabanwar2101 5 лет назад
I don't understand why I have to write a callback to sort! I already provided array of integers! Totally unexpected!
@LawZist
@LawZist 6 лет назад
You are the best!
@NaamJapMantra
@NaamJapMantra 5 лет назад
very nice...
@samirmahmudlu
@samirmahmudlu 4 года назад
Thanks
@Techsithtube
@Techsithtube 4 года назад
Welcome
@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
@TheRaghavboyz
@TheRaghavboyz 6 лет назад
Here we go again.
@spacewad8745
@spacewad8745 6 лет назад
I am really early I deserve love... Jokes aside, great content as usual!
@Techsithtube
@Techsithtube 6 лет назад
Thanks for the first comment:)
@jainshilpi3
@jainshilpi3 6 лет назад
great video sir
@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 5 лет назад
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 2 года назад
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.
@anversadutt
@anversadutt 6 лет назад
NaN === NaN; // false because NaN, and only NaN, will compare unequal to itself.
@priyanshupatel2464
@priyanshupatel2464 3 года назад
ary.sort((a,b)=>aa-b)
@Techsithtube
@Techsithtube 3 года назад
For numbers you need to use a-b
@venkykp174
@venkykp174 3 года назад
Super
@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); }
@brandonrobinson8452
@brandonrobinson8452 5 лет назад
I couldnt find the tutorial on negative indexes. Could someone please point me to it?
@darrylbrian
@darrylbrian 4 года назад
Here it is: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-pFEdFfB2ewE.html
@andrewdeiak6871
@andrewdeiak6871 3 года назад
Nice!
@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.
@mrkaspr
@mrkaspr 4 года назад
whats the reason ary.sort() treated the array as a string?
@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
@abhitmallik3528
@abhitmallik3528 3 года назад
Hello sir, The last question (NaN ===NaN) will give false
@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
@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?!
@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.
@osamatalaat5354
@osamatalaat5354 6 лет назад
Thank you so much ❤❤❤ But Where is the link of the negative index video?!
@darrylbrian
@darrylbrian 4 года назад
Here it is: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-pFEdFfB2ewE.html
@susmitashinkar9095
@susmitashinkar9095 4 года назад
The one you mentioned for sorting is not working
@Techsithtube
@Techsithtube 4 года назад
which particular one?
@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.
@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 5 лет назад
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);
@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
@akab211
@akab211 6 лет назад
Javascript is awesome!
@Techsithtube
@Techsithtube 6 лет назад
indeed :)
@Daniel_WR_Hart
@Daniel_WR_Hart 4 года назад
8:55, but Infinity != 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.
@RishiRaj95
@RishiRaj95 4 года назад
Note:- 0/0 is NaN 1/0 is Infinite
@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 ...
@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
@johnnichols6325
@johnnichols6325 5 лет назад
NAN === NAN returns false
@Bakuta1103
@Bakuta1103 5 лет назад
As a primarily c++ programmer, I am thoroughly confused :)
@Techsithtube
@Techsithtube 5 лет назад
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 .
@jakubmaximilian1419
@jakubmaximilian1419 Год назад
the last question should be printed false
@abhishekkumargupta763
@abhishekkumargupta763 5 лет назад
Output for last will be false,
@yongkiamirson2376
@yongkiamirson2376 3 года назад
IQ I Q......
@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!
@bhavleensingh6929
@bhavleensingh6929 4 года назад
hey! why are checking comments
@lalitkumar50678
@lalitkumar50678 3 года назад
Thanks, Answer is last question is true
@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.
@bapinmalakar3846
@bapinmalakar3846 6 лет назад
Nan is also Nan so return false
@syedfaizan92
@syedfaizan92 5 лет назад
11:53 how did the '6' come in?
@Techsithtube
@Techsithtube 5 лет назад
Because it truncates.
@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
@saranshdhyani3164
@saranshdhyani3164 5 лет назад
After reading javascript Aby kya hai ye isne to programming k fundamentals ko hi palat diya
@muhammadqamar2283
@muhammadqamar2283 6 лет назад
it would be FALSE
@Techsithtube
@Techsithtube 6 лет назад
Yes. it would be false. the only way to check NaN is isNaN() function.
@adyashasahoo4237
@adyashasahoo4237 4 года назад
False, as NaN compared to anything is false
@bhanprakash4179
@bhanprakash4179 5 лет назад
Inside NaN they are different like 57sgt674fyj&6&(6_: === gi3754_76ticc58& That's why they always gives false even with itself
@hrishikeshakolkar5703
@hrishikeshakolkar5703 6 лет назад
false, coz NaN is falsy
@Techsithtube
@Techsithtube 6 лет назад
Yes, That is right!
Далее
Tricky JavaScript interview questions and answers
21:01
Async Await JavaScript ES7
26:39
Просмотров 120 тыс.
Tricky JavaScript Interview Questions and Answers
16:35
Answering tricky JavaScript interview questions
35:16
Top 5 JavaScript Interview Questions with Answers!
29:33
Top 10 JavaScript Interview Questions ( Part 2 )
13:05
Просмотров 291 тыс.