Это видео недоступно.
Сожалеем об этом.
Deep Copy vs Shallow Copy | Javascript Interview questions and answers in hindi
HTML-код
- Опубликовано: 14 авг 2024
- Wondering the difference between Deep Copy and Shallow copy or how to deep copy objects in javascript and it was very import to understand this in depth about shallow copy, ways to shallow copy, deep copy and the best way to deep copy.
I have tried to cover all these methods in this video which will help you to understand this concept in depthWe will also see what happens behind the scenes in the browser when you use them in code.
Good Luck,
Sofia Goyal
If you like my work you can support me and buy me a coffee at:
buy.stripe.com...
00:00 - Introduction
00:44 - Normal copy
02:24 - Shallow Copy
03:36 - Issues with shallow copy
05:52 - Deep copy
07:00 - issue with json stringify and parse
09:49 - using lodash
11:12 - Thank you for watching 🙏
My Nagarro interview experience:
• Nagarro Interview Expe...
How I got a job in germany
• How To Get a Job in Ge...
Javascript interview questions series:
• Javascript Interview Q...
- If you are looking for resume making tips, please checkout :
• How to Make a Resume |...
- If you are willing to become a web developer, check this out :
• How to become a Web De...
- For other interview tips and job change tips:
• how to get job during ...
• how to prepare for an ...
• interview tips and tec...
I will keep making these tutorials and will try to put my best into this so that i can provide you with the most relevant content.
Please keep supporting and if you like it please share with your friends.
Stay Connected:
Linkedin : / sofia-goyal
Facebook : / sofigoyal14
Instagram : / sofi_goyal
Twitter : / sofiagoyal14
#JavaScriptInterviewQuestions #JavaScriptInterviewQuestionsandanswers #JavaScriptTutorial #sofiagoyal #mostaskedinterviewquestions #deepcopyvsshallowcopy #sofiagoyal
Thank you very much😄
love your work you just make it very simple and clear that too with giving each and every exact tiny detail ,may godbless you❤️
Thanks a lot 🙏
ZABARDAST ... CONTINUE RAKHIEN APNAY LECTURES ...
Taught us in a very nice manner and not consumed lot of time.........
Nice explanation now I am clearing my all doubts.
Good one... Appreciate the explanation.. I'm ready to face this question now😎
Good to know that 🙂
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
Superb yr...keep going... 👍
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.
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
@@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]
@@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 👍
simply excellent....
You are a great teacher. I have started to see you js playlist. it is very good.
Thanks 🙏 react tutorials are also coming soon if you are interested
hi...
very informative .
Thanks 🙏
beauty with knowledge killer combo thanks a lot
so knowledgeable
Awesome explanation 🙂.
Knowledgeable Content👍
Well Explained...
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.
Coming up with closures soon...
great information for new man job interview
Thanks..
Thanks a lot
Wonderfully explained. 👍
Thanks buddy... 🙃
Thanks alot 👍
Nice 👌
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
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.. 👍
@@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..
Mam ap esse hi videos laya kijiye so that we can crack the interview
Sure... Working on more... 😊
Hi mam,
I am giving the interview in front end how can I practice tricky js question.
I think you need to know js in depth, then you will be able to solve them all
please pick all the topics to js ...
Mam mera error a raha Uncaught TypeError: JSON.stringfy is not a function
stringify ki spelling yaha galat hai to program m bh hogi
Mam Event loop Javascript ka video bna do kafi puchte hai interview mai pr actual mai niii pta
Sure... Will Come with that soon...
mam object.seeze and object.freez par video banaea.
Sure.. Will try
@@SofiaGoyal mam sorry it is Object.freeze vs Object.seal ess par videos banaea.
mam clone deep nahi mill raha extention me.
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/
Ye concept koye java mai bhi bta do:(
Thanks a lot