Top Tricky JavaScript Interview Questions and Answers

Поделиться
HTML-код
  • Опубликовано: 18 ноя 2024
  • НаукаНаука

Комментарии • 203

  • @anand10parmar
    @anand10parmar 5 лет назад +58

    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 лет назад +2

      Thanks, I was reading the comments for this.

    • @abdelkrimhaddadi5098
      @abdelkrimhaddadi5098 5 лет назад +6

      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 года назад +2

      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 года назад +1

      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 лет назад +3

    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 6 лет назад +11

    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 лет назад +1

      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 лет назад +58

    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 лет назад +15

      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 лет назад +4

      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.

  • @4ipon4ik
    @4ipon4ik 2 года назад +8

    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...

  • @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 лет назад +56

    NaN compared to anything is always false, even comparing to itself!

    • @Techsithtube
      @Techsithtube  6 лет назад +13

      That is the right answer. :)

    • @gidmanone
      @gidmanone 6 лет назад +1

      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 лет назад +8

      But isNan(Nan) will be true;
      isNan('hello') will be true
      Number.isNan('hello;) will be false.
      JS is killing me)

  • @mendelson-dev
    @mendelson-dev 5 лет назад +1

    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).

  • @dantegreyson2014
    @dantegreyson2014 6 лет назад +2

    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 лет назад +2

      yes because its JavaScript :) Basically it try to convert array to string.

  • @sayedabdulkarim7086
    @sayedabdulkarim7086 5 лет назад +2

    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]

  • @shubhamarora1441
    @shubhamarora1441 3 года назад +2

    Your videos are great. They are short but covers a lot. Keep doing the great work 👍🏻

  • @SameerUnt
    @SameerUnt 5 лет назад +1

    2:31 index doesn’t mean to find the value. Its like find me the location of that value.

  • @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;
    }));

  • @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 🙂.

  • @deepakgour2372
    @deepakgour2372 4 года назад +6

    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 года назад +1

      i was doing a project work and came across this issue related to 18 digit number

  • @osamatalaat5354
    @osamatalaat5354 6 лет назад +1

    Thank you so much
    We wanna a separate Playlist to all of the Tricky Javascript interview questions videos

  • @MrAmarJK
    @MrAmarJK 5 лет назад +2

    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;

  • @HaraHaraMahadev777
    @HaraHaraMahadev777 5 лет назад +1

    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

  • @GabrielVasile
    @GabrielVasile 5 лет назад +1

    Another way of adding two arrays together and display them as a string is this: [1,2,3].concat([4,5,6]).toString()

  • @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 ===

  • @naveenreddydepa8324
    @naveenreddydepa8324 6 лет назад +3

    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. :)

  • @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

  • @Roysameer3986
    @Roysameer3986 4 года назад +1

    Use Number.isNaN(NaN) to compare it will return true

  • @YambeeStarVideo
    @YambeeStarVideo 5 лет назад +1

    8:44 - wrong. MAX_VALUE multiplies to Infinity, not 0

  • @aniketverma4434
    @aniketverma4434 2 года назад

    Love the way you explain ❤

  • @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

  • @Harshavardhan-gd4eu
    @Harshavardhan-gd4eu 6 лет назад +1

    Great Video as always :) Thanks for making JavaScript so easier to learn :) .

  • @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

  • @asingb
    @asingb 6 лет назад +1

    👍 cool experiments with js. thank you sir.

  • @TheRaghavboyz
    @TheRaghavboyz 6 лет назад +4

    Here we go again.

  • @devolee8302
    @devolee8302 6 лет назад

    I really enjoy these series. Thanks you sir!

  • @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...

  • @kanishmishra4716
    @kanishmishra4716 5 лет назад +1

    sorting is not working using arr.sort((a,b)=>{return a

    • @abdelkrimhaddadi5098
      @abdelkrimhaddadi5098 5 лет назад +2

      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]

  • @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.

  • @sreenathreddy1239
    @sreenathreddy1239 5 лет назад

    I loved it, Can i have quations like this of angularJS 1.x as well?

  • @kamaboko1
    @kamaboko1 6 лет назад +1

    I enjoy these JS questions videos.

  • @BenSmith-et9fv
    @BenSmith-et9fv 6 лет назад

    I like that interview series. thanks!

  • @pravini2116
    @pravini2116 4 года назад

    console.log(NaN === NaN);it returns false,beacause we dont know what exactly number we are doing operations.:-)

  • @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 лет назад +2

      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

  • @shadabanwar2101
    @shadabanwar2101 5 лет назад

    I don't understand why I have to write a callback to sort! I already provided array of integers! Totally unexpected!

  • @nofavors
    @nofavors 6 лет назад

    more homeworks pls.. specially coding problems and interview tasks

  • @greatgoblinonizuka12
    @greatgoblinonizuka12 6 лет назад

    i love your accent it's very clear!

  • @sureshmg6786
    @sureshmg6786 5 лет назад

    Very tricky and helpful!

  • @prabhukadode723
    @prabhukadode723 6 лет назад +1

    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.

  • @Amit-oz9vr
    @Amit-oz9vr Год назад

    If Type(x) is Number, then
    If x is NaN, return false.
    If y is NaN, return false.

  • @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.

  • @kamal-ahmed
    @kamal-ahmed 6 лет назад

    Nice video. Thanks for your hard work and time.

  • @marcmoo9130
    @marcmoo9130 6 лет назад +1

    null===null give you true,NaN==NaN give false

    • @Techsithtube
      @Techsithtube  6 лет назад

      You got it. Thanks for the response.

  • @erez7020
    @erez7020 5 лет назад +3

    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 года назад +1

      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!

  • @ascukins
    @ascukins 6 лет назад

    Thanks ) Love your videos!

  • @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

  • @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

  • @swapnilpakolu4395
    @swapnilpakolu4395 5 лет назад +1

    Great 👍

  • @TheRaghavboyz
    @TheRaghavboyz 6 лет назад

    Love your videos man.

  • @abhitmallik3528
    @abhitmallik3528 4 года назад

    Hello sir,
    The last question (NaN ===NaN) will give false

  • @osamatalaat5354
    @osamatalaat5354 6 лет назад +2

    Thank you so much ❤❤❤
    But Where is the link of the negative index video?!

    • @darrylbrian
      @darrylbrian 4 года назад

      Here it is: ruclips.net/video/pFEdFfB2ewE/видео.html

  • @sergeymigel4680
    @sergeymigel4680 4 года назад

    Thank you, Man!

  • @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

  • @samirmahmudlu
    @samirmahmudlu 4 года назад +1

    Thanks

  • @venkateshvenkat2302
    @venkateshvenkat2302 5 лет назад +1

    Thank you so much sir

  • @Chillwire-c2b
    @Chillwire-c2b 3 года назад

    sir ascending & descending order code is not working it gives same array

  • @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?!

  • @brandonrobinson8452
    @brandonrobinson8452 5 лет назад +1

    I couldnt find the tutorial on negative indexes. Could someone please point me to it?

    • @darrylbrian
      @darrylbrian 4 года назад

      Here it is: ruclips.net/video/pFEdFfB2ewE/видео.html

  • @mrkaspr
    @mrkaspr 4 года назад

    whats the reason ary.sort() treated the array as a string?

  • @scorpio9ification
    @scorpio9ification 6 лет назад +1

    Liked before watching crew

  • @priyanshupatel2464
    @priyanshupatel2464 3 года назад

    ary.sort((a,b)=>aa-b)

  • @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 лет назад +1

      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);

  • @NaamJapMantra
    @NaamJapMantra 5 лет назад +1

    very nice...

  • @meetshujah
    @meetshujah 6 лет назад +1

    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.

  • @mohaklondhe3020
    @mohaklondhe3020 3 года назад

    why maxvalue - maxvalue gives maxvalue, and not zero

  • @jainshilpi3
    @jainshilpi3 6 лет назад

    great video sir

  • @anversadutt
    @anversadutt 6 лет назад

    NaN === NaN; // false
    because NaN, and only NaN, will compare unequal to itself.

  • @LawZist
    @LawZist 6 лет назад

    You are the best!

  • @petrzavadskii7179
    @petrzavadskii7179 2 года назад

    Last statement is results by false thus one NaN not equal to another NaN

  • @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 ...

  • @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 лет назад +1

      Its basically how the sort is implemented in javaScript other languages a>b makes sense but javaScript decided to go this way.

  • @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

  • @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.

  • @spacewad8745
    @spacewad8745 6 лет назад +1

    I am really early I deserve love... Jokes aside, great content as usual!

  • @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!

  • @venkykp174
    @venkykp174 3 года назад

    Super

  • @andrewdeiak6871
    @andrewdeiak6871 3 года назад

    Nice!

  • @susmitashinkar9095
    @susmitashinkar9095 4 года назад

    The one you mentioned for sorting is not working

  • @bhavleensingh6929
    @bhavleensingh6929 4 года назад

    hey! why are checking comments

  • @Bakuta1103
    @Bakuta1103 6 лет назад

    As a primarily c++ programmer, I am thoroughly confused :)

    • @Techsithtube
      @Techsithtube  6 лет назад +2

      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 .

  • @akab211
    @akab211 6 лет назад +1

    Javascript is awesome!

  • @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);
    }

  • @RishiRaj95
    @RishiRaj95 5 лет назад

    Note:-
    0/0 is NaN
    1/0 is Infinite

  • @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...

  • @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

  • @Daniel_WR_Hart
    @Daniel_WR_Hart 4 года назад

    8:55, but Infinity != 0

  • @syedfaizan92
    @syedfaizan92 6 лет назад

    11:53 how did the '6' come in?

  • @abhishekkumargupta763
    @abhishekkumargupta763 5 лет назад

    Output for last will be false,

  • @lalitkumar50678
    @lalitkumar50678 3 года назад

    Thanks,
    Answer is last question is true

  • @johnnichols6325
    @johnnichols6325 5 лет назад +1

    NAN === NAN returns false

  • @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.

  • @jakubmaximilian1419
    @jakubmaximilian1419 Год назад

    the last question should be printed false

  • @bapinmalakar3846
    @bapinmalakar3846 6 лет назад

    Nan is also Nan so return false

  • @yongkiamirson2376
    @yongkiamirson2376 3 года назад

    IQ
    I Q......