Tricky JavaScript interview questions and answers

Поделиться
HTML-код
  • Опубликовано: 1 окт 2024
  • Top 10 Trickiest weirdest JavaScript Interview Questions and their possible answers ( path to crack tough JS interview )
    Please be my patreons on patreaon
    * / techsith
    Follow me for technology updates
    * / techsith
    * / techsith1
    Help me translate this video.
    *

Комментарии • 1,1 тыс.

  • @vinodhkumar457
    @vinodhkumar457 6 лет назад +82

    This one is important for JS developers.

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

      Thanks for watching ! :) Thanks for the support ! )

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

      Very helpful, your you defeated the Google beast

  • @rojiherrera
    @rojiherrera 6 лет назад +21

    "This is an INTERVIEW, not a RACE" -techsith ☝️

  • @zajebojca
    @zajebojca 6 лет назад +37

    This question with "returning total number of arguments" can be solved in much simpler way.
    const x = function(){
    return arguments.length;
    }
    The object 'arguments' has property ''length'.

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

      You are either wrong or you mean the opposite.
      the below returns 4
      function x(a,r,t){
      return arguments.length;
      }
      console.log(x(5,5,6,7))

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

      you can count formal parameters (aka "required arguments") with function.length, not arguments.length, which is a count of what's passed.

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

      I was thinking the same thing, but also what's the point of no loops? How would a loop even help solve this problem lol.

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

      output will be 4

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

      x(.....) function will return how many arguments you are passing while calling x(....).

  • @astro-zodiac
    @astro-zodiac 2 года назад +2

    6:10
    That's a cool trick to impress your co-workers,
    If they dont know it 😂😂

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

    For getting total number of arguments, in ES6 we can do
    let x = function (...args) {
    return args.length;
    }
    and for the method chaining we can use
    return this;

  • @pavelerokhin1512
    @pavelerokhin1512 6 лет назад +22

    There is no inappropriate content in this video, dear RUclips

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

    This is great, I have a couple of job interviews next week for JavaScript roles and you have really helped me to build my confidence in preparation for this. Please keep posting videos :-)

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

    'Document.body.cotentEditable = "true" ' is super cool !!!

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

      Yes first time i saw contentEditable I was blown away. :)

  • @xuelianwang5300
    @xuelianwang5300 5 лет назад +5

    Very interesting JavaScript question! Thank you for sharing!! Thank you for taking time and effort to make so many nice JavaScript videos!

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

    This video is great but and your explanation is good.
    I really did't understand the concept of asking these kind of questions in interview. Until and unless you faced these kind of scenarios in real time you never know the answer. I do have some decent experience like 6+ in JS but I faced these situations very rare when we work on framework. (9 out of 10 developers dont remember things after fixing an issue)
    So if some one answered these kind of questions means they saw these videos(assume {some number} out of 10) or read somewhere. So what are you interviewing real time experience or some interview preparation ?
    As an interviewer I will ask concepts(not these tongue twisters). architecture of application/framework and mainly approach on solving problem and wiling to learn.

  • @ArjunKesava
    @ArjunKesava 5 лет назад +4

    To print the length of arguments (17:33), we can simply write:
    return arguments.length;
    inside the function instead of using Slice method.

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

      That is true Arjun. Slice helps to convert argument to an array and then you can use other array features like join() and things.

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

    Hi, Please elaborate as why arguments[0]() is causing this.length as 2. What makes arguments behave like that.

  • @LolowBlazee
    @LolowBlazee 6 лет назад +8

    Love those tricky questions, we actually keep learning :)

  • @AjayKumar-pp3ys
    @AjayKumar-pp3ys 5 лет назад +1

    Hi Thanks for video but I have a doubt
    String({}) +String([]) will give me "[object Object]"
    but {} + [] will results in 0
    Can you tell me the reason behind this?

  • @vinikett9114
    @vinikett9114 4 года назад +4

    Brother you are one of the most efficient teachers for teaching programming on youtube that i could find.You explain concepts really well.Its sad that youtube is doing this to constructive youtubers like you.You have all my support!

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

    Very informative video . it's really help me. Thank You Sir

  • @ryanlozon5712
    @ryanlozon5712 6 лет назад +7

    Please keep up the awesomeness.

  • @jomesias
    @jomesias 4 года назад +2

    I’m just here to tell youtube this video is important!!

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

    I've been watching your videos over the past few days and they've been extremely helpful and informative!

  • @sistlavenkatesh2993
    @sistlavenkatesh2993 3 года назад +1

    This video is important video for ui developers. Very informative video infact.

  • @momentswithmanisha
    @momentswithmanisha 4 года назад +3

    I learned new things. Thank you clearing my Concept 😇

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

    Thanks for making this video which helps me understand tricky concepts of JavaScript. Thanks a bunch

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

    Thanks for tricky question - didn't aware of this magic

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

    Why don't you use a simplier way to figure out how many arguments the function has received?
    let x = function () {
    return arguments.length;
    }
    console.log(x(1,2,3,4,5))

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

      Yes, that is the solution . I have a habit converting arguments object to an array . :)

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

    Thanks! Great video!
    Hope RUclips will change its policy, keep it up please)

  • @TarunKumar-ne7ng
    @TarunKumar-ne7ng 5 лет назад +2

    very good videos

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

    my first javascript interview coming up very soon

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

    There is no inappropriate content in this video, dear RUclips

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

    Getting ready for my first interview, your content is really helpful

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

      Good luck with your interview. !

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

    I am following you since couple of months.. You are champ man. Keep it up.. 1000 likes from my side

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

      Hi Subrat, thanks for watching! :)

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

    One of the best tutorial :)

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

    Awesome tutorials man.

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

    your videos are awesome and RUclips is very discouraging. Keep up the good work sir.

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

    Best Interview series!

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

    There is nothing inappropriate in this video RUclips. Grow up, this is really frustrating for the admin/owner of page as he is working so hard on content and good things.

  • @SK-ur3hw
    @SK-ur3hw 6 лет назад +5

    Great interview questions 👍🏻

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

    Very helpful input, many thanks

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

    Nice video, keep up the good work! (:

  • @sunnychaudhary35
    @sunnychaudhary35 3 года назад +1

    superb tricky questions. thank you so much and it is really appreciable.

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

    Thanks for making this video. Its a great help for guys like us.

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

    really helpful for learning strange things about javascript.

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

      Ishan, yes JS is strange and I find new strange things every single day.

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

    Thanks sir

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

    Nice video I just feel awesome and think it about in different prospective so please update more more videos to learn more and moRe

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

    Very great Job. Tha k you so much

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

    Good video. Posting comments so youtube can get off your back.

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

    you are great at teaching. very useful examples to understand js

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

      Thank you Diksha, Keep on learning!

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

    I liked even before video started

  • @007souravray
    @007souravray 3 года назад +1

    this video is important for JavaScript developers !!

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

    we can get the total number of argument simply using arguments.length right?
    let x = function(){
    return arguments.length;
    }
    console.log(x(1,2,3,4,5))

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

    Good educational video. 👍

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

    Very helpful videos

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

    Love yours videos tech sith

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

    This video is important

  • @mihirbhakta1
    @mihirbhakta1 3 года назад +1

    This video does not contain any inappropriate content and can be accessible to all ages..

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

    that thing at 3:50 must be the stupidest thing that javascript allows us to make.

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

      Yes, among the other stupidest things that javaScript allows us to make :)

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

    1) "[object Array][object Array]" Failed
    2) "hello" Success
    3) You would need an extension Failed
    4) undefined Failed
    5) "1" Success
    6) 0.30000000000000001 I checked it and in 64-bit the answer is correct
    7) null Success
    8) function(){ return arguments.length }
    9) var A={
    x:function(){
    console.log("x");
    return this;
    },
    y:function(){
    console.log("y");
    return this;
    },
    z:function(){
    console.log("z");
    return this;
    },
    }; Success

  • @yfzhangphonn
    @yfzhangphonn 3 года назад +1

    I really like this video

  • @ShivamGupta-th3ud
    @ShivamGupta-th3ud 5 лет назад +1

    very important video.

  • @sanjaysingh-sy6zu
    @sanjaysingh-sy6zu 5 лет назад +1

    Thanks for making this video which helps me understand tricky concepts of JavaScript. Thanks a bunch

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

    Good video to understand JavaScript concepts in depth

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

    Hi,
    For simplicity of typing I have used iife...
    Why you have done like this ? any benefit?
    (function x (a , b, c, d) {
    return [].slice.call(arguments).length;
    })(1, 2, 3, 4);
    Instead of simply returning length of arguments array like-
    (function y (a , b, c, d) {
    return arguments.length;
    })(1, 2, 3, 4);
    Thanks,
    Rahul

  • @АндрейКаменский-ш4б

    2 more easy way to get the numbers of arguments
    const x = (...a) => a.length;
    console.log(x(1, 2, 3, 4)); //4
    let y = function (){return arguments.length };
    console.log(y(1, 2, 3, 4, 5, 6, 7)); //7

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

    Superb boss

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

    @17.25, a more concise solution is: const x = (...rest) => rest.length;
    Awesome video, Techsith. I'm 100% subbed 🏆🎊. Most of these questions really had be thinking haha

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

    If my job interview clear I will donate on patron.

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

      I appreciate the gesture Rushabh. Thank you for watching!

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

    very informative

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

    Hey "youtube" if you are listening "THIS VIDEO IS VERY VERY IMPORTANT FOR US DID YOU UNDERSTAND!".

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

    good one

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

    Awesome video! :)

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

    Great video 👍🏻

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

    Hey Bro,
    Your Sessions are great but kindly do update the answers based on current browser version i checked console.log({} + []) and i have received "[object Object]" because on typecasting the object we get Sting({}) --> "[object Object]"

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

    Thanks for your work.
    console.log(arguments.length);
    vs
    console.log([].slice.call(arguments).length);

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

    Very well explained. Thanks Sith

  • @RahulSingh-ve2qx
    @RahulSingh-ve2qx 5 лет назад +1

    Really helpful :)

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

    function a() {
    console.log(arguments.length);
    }
    Above will also work for arguments length.

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

    best video (Y)

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

    Useful video

  • @ernestromen1479
    @ernestromen1479 6 месяцев назад

    You helped me a lot in job interviews.
    Actually I am preparing for an interview right now with the help of your video.
    Thank you!

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

    Good question

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

    ty

  • @MrBuldozeris
    @MrBuldozeris 2 года назад +1

    great video

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

    Thankful for good bunch of Interview questions ons JS.

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

    All the videos are career-boosting!!!

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

      Glad you fee that way. Thanks for the support.

  • @Ray-Zah
    @Ray-Zah 6 лет назад

    instead of document.body.contentEditable = true; you could also use document.designMode = 'on';

  • @1997jugulator
    @1997jugulator 3 года назад

    arguments is ArrayLike, so .length is available without magic with array object and borrowing function. But most of questions quite interesting,

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

    Nice.. on the contrary google should come up with new things to sort out issue w.r.t to ads..
    Now a days utubers are getting views just by imposter thumnails..
    And here utube just fails to recognize nice content like yours..

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

    about function returns total number of arguments: Isn't it easier doing something like the following? Thanks!
    let x = function(){
    return arguments.length;
    }

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

    question : function return total number of arguments. // do not use loops.
    let x = function(){
    return [].slice.call(arguments).length;
    }
    Below one is more simple :
    let x = function(){
    return arguments.length;
    }

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

    Awesome video

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

    Great video

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

    great video

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

    Good content!

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

    nice trick...

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

    This is very helpful to understand JavaScript internal technical execution and it's improve my knowledge

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

    console.log({}+[])
    gives [Object Object]...kindly explain.

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

    / It is not possible to determine the total number of arguments without using any loops or iterative constructs. In order
    // to count the total number of arguments, you will need to use some form of loop to iterate over the arguments and increment
    // a counter for each one.
    // In JavaScript, you can access the arguments passed to a function using the arguments object, which is an array-like object that
    // contains the values of the arguments. You can use a for loop to iterate over the arguments object and count the number of arguments. Alternatively, you can use the Array.prototype.length property to get the number of elements in the arguments object.

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

    function x(){return arguments.length;} this also works then is there are any specific reason to use [].slice.call(arguments).length ?

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

    good content

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

    hello i was trying the first one consol.e.log({} + []); object + array that's are empty.Is the output an object is that correct? I am confused.

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

    What's the point of converting the arguments object into a real array (17:01)? The arguments object has the length property. You could just have returned arguments.length