Deep Copy vs Shallow Copy | Javascript Interview questions and answers in hindi

Поділитися
Вставка
  • Опубліковано 18 гру 2024

КОМЕНТАРІ • 54

  • @shwetamishra8992
    @shwetamishra8992 Рік тому

    Nice explanation now I am clearing my all doubts.

  • @rishabhpratapsingh5304
    @rishabhpratapsingh5304 2 роки тому

    Taught us in a very nice manner and not consumed lot of time.........

  • @Muhammad-Ahmer.
    @Muhammad-Ahmer. 9 місяців тому

    ZABARDAST ... CONTINUE RAKHIEN APNAY LECTURES ...

  • @sagarmahey
    @sagarmahey 6 місяців тому

    love your work you just make it very simple and clear that too with giving each and every exact tiny detail ,may godbless you❤️

  • @janiirigi907
    @janiirigi907 2 роки тому +1

    Good one... Appreciate the explanation.. I'm ready to face this question now😎

  • @gauravpise6393
    @gauravpise6393 Рік тому

    You are a great teacher. I have started to see you js playlist. it is very good.

    • @SofiaGoyal
      @SofiaGoyal  Рік тому +1

      Thanks 🙏 react tutorials are also coming soon if you are interested

  • @notappi3982
    @notappi3982 Рік тому

    beauty with knowledge killer combo thanks a lot

  • @NKG_Creations
    @NKG_Creations 4 місяці тому

    Thank you very much😄

  • @Harshitbadolla
    @Harshitbadolla 2 роки тому +3

    I didn't know that the function won't get copied using stringify. Thanks for pointing that out and here is the solution to the homework problem
    let person = {
    firstName: "Harshit",
    lastName: "Badolla",
    fullName(){
    return `${this.firstName} is ${this.lastName}`;
    }
    };
    let keys = Object.keys(person);
    function deepCopy(arr) {
    const newObj = {}
    for(let i = 0; i

    • @SofiaGoyal
      @SofiaGoyal  2 роки тому +1

      Superb yr...keep going... 👍

    • @Harshitbadolla
      @Harshitbadolla 2 роки тому

      We can improve the solution by passing an object as an argument and moving the keys variable inside the function deepcopy...this way it will become more like the lodash method which you used in the video. Let me know what you think? Also lodash method will check for all corner cases but the function which i wrote can also be used.

    • @Harshitbadolla
      @Harshitbadolla 2 роки тому

      let person = {
      firstName: "Harshit",
      lastName: "Badolla",
      fullName(){
      return `${this.firstName} is ${this.lastName}`;
      }
      };
      function deepCopy(obj) {
      let keys = Object.keys(person);
      const newObj = {}
      for(let i = 0; i

    • @namratagiri4240
      @namratagiri4240 2 роки тому

      @@Harshitbadolla this is still the shallow copy not deep copy..
      Try with below obj
      let person = {
      firstName: "Harshit",
      lastName: "Badolla",
      address: {
      location: 'Pune',
      hometown: 'Mumbai'
      },
      fullName(){
      return `${this.firstName} is ${this.lastName}`;
      }
      };
      If we change address.location for one object it gets changed for another object too.
      @sofia Can you suggest how we can make it deepcopy (and make it work for nested objs too)?
      [I am also trying, will post here if I find soln]

    • @Harshitbadolla
      @Harshitbadolla 2 роки тому +1

      @@namratagiri4240
      const deepCopyFunction = (inObject) => {
      let outObject, value, key
      if (typeof inObject !== "object" || inObject === null) {
      return inObject // Return the value if inObject is not an object
      }
      // Create an array or object to hold the values
      outObject = Array.isArray(inObject) ? [] : {}
      for (key in inObject) {
      value = inObject[key]
      // Recursively (deep) copy for nested objects, including arrays
      outObject[key] = deepCopyFunction(value)
      }
      return outObject
      };
      I got the above solution from here -
      javascript.plainenglish.io/how-to-deep-copy-objects-and-arrays-in-javascript-7c911359b089
      Thanks for pointing out...I got to learn something new.
      Also it is always best to use a library to deep copy like lodash as there will be lot of corner cases which needs to be taken care of. All the best 👍

  • @SAMEERKHAN-nd7ti
    @SAMEERKHAN-nd7ti 2 роки тому

    simply excellent....

  • @ShivamSharma-uc8pu
    @ShivamSharma-uc8pu 2 роки тому +1

    Good one, I would like to see concept of functional programming in js like HOC with prons and cons and closures with prons and cons.

    • @SofiaGoyal
      @SofiaGoyal  2 роки тому

      Coming up with closures soon...

  • @ghulammehdisoomro7980
    @ghulammehdisoomro7980 2 роки тому

    great information for new man job interview

  • @rahulwadile4785
    @rahulwadile4785 2 роки тому

    so knowledgeable

  • @sarimali1584
    @sarimali1584 Рік тому

    hi...
    very informative .

  • @AmitKumar-gg5gj
    @AmitKumar-gg5gj 2 роки тому

    Wonderfully explained. 👍

  • @shubhampawar732
    @shubhampawar732 2 роки тому

    Well Explained...

  • @jagdishjena9058
    @jagdishjena9058 2 роки тому

    Mam ap esse hi videos laya kijiye so that we can crack the interview

    • @SofiaGoyal
      @SofiaGoyal  2 роки тому +1

      Sure... Working on more... 😊

  • @whitecodecamp
    @whitecodecamp 2 роки тому

    Knowledgeable Content👍

  • @BooksBelievers09
    @BooksBelievers09 2 роки тому

    Awesome explanation 🙂.

  • @nilesh906
    @nilesh906 2 роки тому

    Nice 👌

  • @kewalkandpal
    @kewalkandpal 2 роки тому

    Thanks a lot

  • @amitpaple
    @amitpaple 2 роки тому

    Thanks alot 👍

  • @kanikaagarwal3159
    @kanikaagarwal3159 2 роки тому

    Hi mam,
    I am giving the interview in front end how can I practice tricky js question.

    • @SofiaGoyal
      @SofiaGoyal  2 роки тому +1

      I think you need to know js in depth, then you will be able to solve them all

  • @adityatrivedi4820
    @adityatrivedi4820 2 роки тому +1

    Mam , I have started learning JavaScript, CSS and HTML from 2 months...from online resources... Please tell me when can I get a job as frontend developer

    • @SofiaGoyal
      @SofiaGoyal  2 роки тому

      Honestly there is no certain answer to this.. It completely depends on your grasping power... But i am sure that if you keep learning and practicing you will get a job soon... All the best.. 👍

    • @adityatrivedi4820
      @adityatrivedi4820 2 роки тому

      @@SofiaGoyal thanks mam..could u guide me for getting a starting job as Front end developer.. what should i do more to get job ASAP..

  • @jagdishjena9058
    @jagdishjena9058 2 роки тому

    mam clone deep nahi mill raha extention me.

    • @SofiaGoyal
      @SofiaGoyal  2 роки тому

      You need to have lodash added to your project... Clonedeep is a method of lodash...
      www.google.com/amp/s/www.geeksforgeeks.org/lodash-_-clonedeep-method/amp/

  • @wememeslover2548
    @wememeslover2548 2 роки тому

    Mam mera error a raha Uncaught TypeError: JSON.stringfy is not a function

    • @AjayChauhan-dg2nl
      @AjayChauhan-dg2nl Рік тому

      stringify ki spelling yaha galat hai to program m bh hogi

  • @deepakgupta2084
    @deepakgupta2084 2 роки тому

    Mam Event loop Javascript ka video bna do kafi puchte hai interview mai pr actual mai niii pta

    • @SofiaGoyal
      @SofiaGoyal  2 роки тому +1

      Sure... Will Come with that soon...

  • @rehanhaq3564
    @rehanhaq3564 2 роки тому

    please pick all the topics to js ...

  • @jagdishjena9058
    @jagdishjena9058 2 роки тому

    mam object.seeze and object.freez par video banaea.

    • @SofiaGoyal
      @SofiaGoyal  2 роки тому

      Sure.. Will try

    • @jagdishjena9058
      @jagdishjena9058 2 роки тому

      @@SofiaGoyal mam sorry it is Object.freeze vs Object.seal ess par videos banaea.

  • @dominic9714
    @dominic9714 Рік тому

    Ye concept koye java mai bhi bta do:(

  • @chinmayganjiwale6499
    @chinmayganjiwale6499 2 роки тому

    Thanks a lot