Top Tricky JavaScript Interview Questions and Answers

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

techsith

techsith

6 жыл бұрын

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.
* kzfaq.info_vide...
Note: use translate.google.com/ to translate this video to your language. Let me know once you do that so i can give you credit. Thank you in advance.

Пікірлер: 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
@shubhamarora1441
@shubhamarora1441 3 жыл бұрын
Your videos are great. They are short but covers a lot. Keep doing the great work 👍🏻
@osamatalaat5354
@osamatalaat5354 6 жыл бұрын
Thank you so much We wanna a separate Playlist to all of the Tricky Javascript interview questions videos
@mendelson-dev
@mendelson-dev 4 жыл бұрын
it is worth mentioning that when we use "use strict" it will throw the error (example with IIFE)
@devolee8302
@devolee8302 5 жыл бұрын
I really enjoy these series. Thanks you sir!
@ascukins
@ascukins 6 жыл бұрын
Thanks ) Love your videos!
@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 5 жыл бұрын
I like that interview series. thanks!
@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
@TheRaghavboyz
@TheRaghavboyz 6 жыл бұрын
Love your videos man.
@asingb
@asingb 5 жыл бұрын
👍 cool experiments with js. thank you sir.
@sergeymigel4680
@sergeymigel4680 4 жыл бұрын
Thank you, Man!
@sureshmg6786
@sureshmg6786 4 жыл бұрын
Very tricky and helpful!
@kamal-ahmed
@kamal-ahmed 6 жыл бұрын
Nice video. Thanks for your hard work and time.
@kamaboko1
@kamaboko1 6 жыл бұрын
I enjoy these JS questions videos.
@aniketverma4434
@aniketverma4434 2 жыл бұрын
Love the way you explain ❤
@LawZist
@LawZist 6 жыл бұрын
You are the best!
@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.
@sreenathreddy1239
@sreenathreddy1239 5 жыл бұрын
I loved it, Can i have quations like this of angularJS 1.x as well?
@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. :)
@MylesGmail
@MylesGmail 5 жыл бұрын
I tweeted this video! Ty
@swapnilpakolu4395
@swapnilpakolu4395 4 жыл бұрын
Great 👍
@SameerUnt
@SameerUnt 5 жыл бұрын
2:31 index doesn’t mean to find the value. Its like find me the location of that value.
@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.
@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)
@jainshilpi3
@jainshilpi3 6 жыл бұрын
great video sir
@nofavors
@nofavors 6 жыл бұрын
more homeworks pls.. specially coding problems and interview tasks
@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
@technicalstudycorner2510
@technicalstudycorner2510 5 жыл бұрын
very nice...
@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.
@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
@scorpio9ification
@scorpio9ification 6 жыл бұрын
Liked before watching crew
@Techsithtube
@Techsithtube 6 жыл бұрын
Thanks for the like:)
@greatgoblinonizuka12
@greatgoblinonizuka12 5 жыл бұрын
i love your accent it's very clear!
@Techsithtube
@Techsithtube 5 жыл бұрын
Thank you :)
@venkateshvenkat2302
@venkateshvenkat2302 4 жыл бұрын
Thank you so much sir
@Techsithtube
@Techsithtube 4 жыл бұрын
Thanks for watching venkatesh.
@HaraHaraMahadev777
@HaraHaraMahadev777 4 жыл бұрын
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
@andrewdeiak6871
@andrewdeiak6871 3 жыл бұрын
Nice!
@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; }));
@dualvideoviralguytalksincar
@dualvideoviralguytalksincar 6 жыл бұрын
Make a series on solving codebyte or someone else js challenges
@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]
@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).
@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
@spacewad8745
@spacewad8745 6 жыл бұрын
I am really early I deserve love... Jokes aside, great content as usual!
@Techsithtube
@Techsithtube 6 жыл бұрын
Thanks for the first comment:)
@samirmahmudlu
@samirmahmudlu 3 жыл бұрын
Thanks
@Techsithtube
@Techsithtube 3 жыл бұрын
Welcome
@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.
@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 🙂.
@DevDoodle5555
@DevDoodle5555 11 ай бұрын
These are JS interview questions straight out of hell 🔥 😂 Thank you so much for your super insightful and quick videos! I love them
@mrkaspr
@mrkaspr 4 жыл бұрын
whats the reason ary.sort() treated the array as a string?
@venkykp174
@venkykp174 3 жыл бұрын
Super
@YambeeStarVideo
@YambeeStarVideo 5 жыл бұрын
8:44 - wrong. MAX_VALUE multiplies to Infinity, not 0
@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?!
@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]
@Roysameer3986
@Roysameer3986 4 жыл бұрын
Use Number.isNaN(NaN) to compare it will return true
@shadabanwar2101
@shadabanwar2101 5 жыл бұрын
I don't understand why I have to write a callback to sort! I already provided array of integers! Totally unexpected!
@prabhukadode723
@prabhukadode723 5 жыл бұрын
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.
@osamatalaat5354
@osamatalaat5354 6 жыл бұрын
Thank you so much ❤❤❤ But Where is the link of the negative index video?!
@darrylbrian
@darrylbrian 4 жыл бұрын
Here it is: kzfaq.info/get/bejne/pqx1l6mXp5jJp3k.html
@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 ===
@TheRaghavboyz
@TheRaghavboyz 6 жыл бұрын
Here we go again.
@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.
@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
@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!
@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
@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()
@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;
@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: kzfaq.info/get/bejne/pqx1l6mXp5jJp3k.html
@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...
@shayna5721
@shayna5721 3 жыл бұрын
sir ascending & descending order code is not working it gives same array
@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.
@saradatadepalli4226
@saradatadepalli4226 5 жыл бұрын
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 5 жыл бұрын
If you watch the video there is another line which is missing here. if you add that you will get expected result.
@jimeejain7986
@jimeejain7986 5 жыл бұрын
X.indexOf(10000). Wrong brackets
@priyanshupatel2464
@priyanshupatel2464 3 жыл бұрын
ary.sort((a,b)=>aa-b)
@Techsithtube
@Techsithtube 3 жыл бұрын
For numbers you need to use a-b
@pravini2116
@pravini2116 3 жыл бұрын
console.log(NaN === NaN);it returns false,beacause we dont know what exactly number we are doing operations.:-)
@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 5 жыл бұрын
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);
@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 ...
@mohaklondhe3020
@mohaklondhe3020 3 жыл бұрын
why maxvalue - maxvalue gives maxvalue, and not zero
@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.
@AlwaysBeTactful
@AlwaysBeTactful Жыл бұрын
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
@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.
@akab211
@akab211 6 жыл бұрын
Javascript is awesome!
@Techsithtube
@Techsithtube 6 жыл бұрын
indeed :)
@abhitmallik3528
@abhitmallik3528 3 жыл бұрын
Hello sir, The last question (NaN ===NaN) will give false
@anversadutt
@anversadutt 6 жыл бұрын
NaN === NaN; // false because NaN, and only NaN, will compare unequal to itself.
@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
@petrzavadskii7179
@petrzavadskii7179 Жыл бұрын
Last statement is results by false thus one NaN not equal to another NaN
@syedfaizan92
@syedfaizan92 5 жыл бұрын
11:53 how did the '6' come in?
@Techsithtube
@Techsithtube 5 жыл бұрын
Because it truncates.
@susmitashinkar9095
@susmitashinkar9095 3 жыл бұрын
The one you mentioned for sorting is not working
@Techsithtube
@Techsithtube 3 жыл бұрын
which particular one?
@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!
@marcmoo9130
@marcmoo9130 5 жыл бұрын
null===null give you true,NaN==NaN give false
@Techsithtube
@Techsithtube 5 жыл бұрын
You got it. Thanks for the response.
@Amit-oz9vr
@Amit-oz9vr 10 ай бұрын
If Type(x) is Number, then If x is NaN, return false. If y is NaN, return false.
@bhavleensingh6929
@bhavleensingh6929 4 жыл бұрын
hey! why are checking comments
@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
@Daniel_WR_Hart
@Daniel_WR_Hart 4 жыл бұрын
8:55, but Infinity != 0
@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 .
@abhishekkumargupta763
@abhishekkumargupta763 5 жыл бұрын
Output for last will be false,
@lalitkumar50678
@lalitkumar50678 3 жыл бұрын
Thanks, Answer is last question is true
@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!
@yongkiamirson2376
@yongkiamirson2376 2 жыл бұрын
IQ I Q......
@RishiRaj95
@RishiRaj95 4 жыл бұрын
Note:- 0/0 is NaN 1/0 is Infinite
@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
@jakubmaximilian1419
@jakubmaximilian1419 Жыл бұрын
the last question should be printed false
Tricky JavaScript interview questions and answers
21:01
techsith
Рет қаралды 132 М.
Survival skills: A great idea with duct tape #survival #lifehacks #camping
00:27
Nutella bro sis family Challenge 😋
00:31
Mr. Clabik
Рет қаралды 13 МЛН
1 or 2?🐄
00:12
Kan Andrey
Рет қаралды 58 МЛН
JavaScript Interview questions everyone gets wrong
6:40
Catherine Li
Рет қаралды 25 М.
40+ MOST COMMONLY Asked Questions [JS, CSS, HTML]
16:17
A Software Engineer
Рет қаралды 38 М.
Async Await JavaScript ES7
26:39
techsith
Рет қаралды 120 М.
Tricky JavaScript Interview Questions and Answers
16:35
techsith
Рет қаралды 456 М.
Medium Google Coding Interview With Ben Awad
51:27
Clément Mihailescu
Рет қаралды 1,2 МЛН
REAL CSS Interview Questions
5:33
Peter Elbaum
Рет қаралды 23 М.
Top 10 JavaScript Interview Questions ( Part 2 )
13:05
techsith
Рет қаралды 291 М.
Handmade Hero | Getting rid of the OOP mindset
7:44
vexe
Рет қаралды 101 М.
Easy Art with AR Drawing App - Step by step for Beginners
0:27
Melli Art School
Рет қаралды 14 МЛН
Cheapest gaming phone? 🤭 #miniphone #smartphone #iphone #fy
0:19
Pockify™
Рет қаралды 2,9 МЛН
Я УКРАЛ ТЕЛЕФОН В МИЛАНЕ
9:18
Игорь Линк
Рет қаралды 118 М.
Samsung laughing on iPhone #techbyakram
0:12
Tech by Akram
Рет қаралды 432 М.