Тёмный

Storing Objects with Local Storage in JavaScript 

dcode
Подписаться 134 тыс.
Просмотров 168 тыс.
50% 1

The limitations of using Local Storage in JavaScript is that you are only able to store data as Strings. In this video, I take you through how to work around this and make it possible to store complex objects with Local Storage.
We can achieve this by serializing (JSON.stringify) the object to store it, and then de-serializing (JSON.parse) it to access it again.
Check this out:
developer.mozi...
Follow me on Twitter @dcode!
If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
#dcode #javascript #webdev

Опубликовано:

 

8 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 79   
@Agustin-jo8mv
@Agustin-jo8mv 2 года назад
I think this is the most basic explanation on local storage thank you. I have really been having a rough time getting my head around this simple concept. lol
@erikdong
@erikdong 2 года назад
Thank you for making this breakdown and walk through! Super helpful.
@silviatriscova433
@silviatriscova433 5 лет назад
This explanation helped me A LOT, thanks!!!
@dcode-software
@dcode-software 5 лет назад
No problems at all mate, cheers
@stardust6998
@stardust6998 4 месяца назад
amazing breakdown, thanks for the straight forward explanation!
@xsocalxryan
@xsocalxryan 10 месяцев назад
Excellent explanation of local storage. Other videos I've watched really complicated it. Thanks!
@morchellemusic2829
@morchellemusic2829 2 года назад
here after you video on js classes, great content thanks
@raven.4815
@raven.4815 Год назад
Simplest video of this topic I've seen, thanks!
@pranitchavan4549
@pranitchavan4549 3 года назад
Damn you really care about naming variables xD Great Video
@mikedev22
@mikedev22 2 года назад
I was stuck on figuring this out. Thanks for the help!
@ministerdjspliff
@ministerdjspliff 5 лет назад
Cheers man. Nice clarification.
@dcode-software
@dcode-software 5 лет назад
You're welcome 😁
@educationaltechnology8363
@educationaltechnology8363 Год назад
Wow! I liked the simplicity! Thanks
@aditgaur1585
@aditgaur1585 3 года назад
Short video but great content, I was stuck the why was it saying [Object object] but this helped a lot, Thanks! :)
@dcode-software
@dcode-software 3 года назад
Glad it helped!
@aditgaur1585
@aditgaur1585 3 года назад
😊
@Ace_Qnemes
@Ace_Qnemes 4 года назад
Super clear and nice explanation. Thanks!
@smurffronda2951
@smurffronda2951 3 года назад
thanks bro so much, have a great week!
@sh9vch9nk0
@sh9vch9nk0 7 месяцев назад
Great video, helped me a lot! Thank you 💓💓👍👍
@coderjag8828
@coderjag8828 2 года назад
Thanks for this explanation!
@BlakeLein
@BlakeLein 2 года назад
Seriously - great video! Super helpful.
@eva354
@eva354 10 месяцев назад
Thank you!
@vaibhav_d7899
@vaibhav_d7899 3 года назад
Great explanation
@sunnyjoshi3405
@sunnyjoshi3405 5 лет назад
Nice..Its really helpfull
@dcode-software
@dcode-software 5 лет назад
Yeah not bad!
@angladephil
@angladephil 5 лет назад
Bravo ! Neat, clear, professional. Thx a lot.
@AndrewOnTestingCars
@AndrewOnTestingCars 4 года назад
Thanks very much! Great video. simple and straight forward
@NghiaTran-lp4xh
@NghiaTran-lp4xh 5 лет назад
what should you do if you wnat to display the value u stored in the storage ? which function would you use to display both name and age ?
@jasongrace6274
@jasongrace6274 3 года назад
This helped. Thanks. I would recommend you to use a dark theme please. This irritates the eye a lot.
@dcode-software
@dcode-software 3 года назад
No problem. All my new videos from like 2019+ are in dark theme
@wduandy
@wduandy 3 года назад
This helped me a lot! Thanks!!
@earnwithvky39
@earnwithvky39 Год назад
Thanks Bro
@anurajms
@anurajms Год назад
thank you
@Chrisallengallery
@Chrisallengallery 3 года назад
You just saved my bacon! Thank you!
@dcode-software
@dcode-software 3 года назад
How? Genuinely curious what you mean by this
@Chrisallengallery
@Chrisallengallery 3 года назад
@@dcode-software It's a British phrase that means 'you just saved me from messing up'. Or in my case, wasting time searching for this solution
@saadelkammah5497
@saadelkammah5497 3 года назад
Thank you so much , but I have question ,Can I trace variables in JS with vs Code as we do with visual studio?
@Omar_Muhammad
@Omar_Muhammad 2 года назад
Thanks.
@angelrivera4491
@angelrivera4491 6 лет назад
hey thank you so much !! good video !!
@dcode-software
@dcode-software 6 лет назад
No worries friend!
@josephafa
@josephafa 4 года назад
Thanks for the vid!
@umardarazofficials3529
@umardarazofficials3529 23 дня назад
Love you 😍😍😍
@hoshi411
@hoshi411 Год назад
How do you recommend storing images? Do you recommend serializing them?
@tjejenathina3829
@tjejenathina3829 2 месяца назад
thanks :)
@setshow9135
@setshow9135 Год назад
Appreciate it
@fahemzoldyck1729
@fahemzoldyck1729 4 года назад
Thanks , very helpful ! Nne of my object's keys has an array as a value. I tried to JSON.stingify the whole thing but the content inside the array was saved an empty array ! do you know maybe why this is happening ?
@pixosdesigne4828
@pixosdesigne4828 3 года назад
u had a mistake at "stingify" => "stringify"
@PurpleGreenLeaf
@PurpleGreenLeaf 2 года назад
Thanks! :-)
@NightDunk
@NightDunk 4 года назад
well explained :)
@antdx316
@antdx316 7 месяцев назад
When it's stored in local storage, what do you do with it as a developer wise?
@718liveyanard4
@718liveyanard4 2 года назад
Can you please say how to display the selected checkbox value and radio button value in next page
@HyperActive94
@HyperActive94 5 лет назад
great video!
@amitj853
@amitj853 Год назад
Until when local storage will hold the data init? Browser's cache is cleared?
@jorgedelcampo6707
@jorgedelcampo6707 5 лет назад
Hi dCode, great video! Please help me. How i can adding multiple json elements to the same storage item?
@dcode-software
@dcode-software 5 лет назад
You could just JSON serialise an array of objects
@hedjerci.g8797
@hedjerci.g8797 3 года назад
WOW explaination
@dimtodim
@dimtodim 5 лет назад
god dammit u r god in less than 7min great job m8 :) do u have video how read date from object on local storage???
@shadowrebels1623
@shadowrebels1623 6 месяцев назад
Simplified ❤❤❤❤✨✨✨✨
@johnvincentjimar4157
@johnvincentjimar4157 2 месяца назад
Explanation is good but why is your vscode on light mode😵
@israelipanda6096
@israelipanda6096 8 месяцев назад
I guess it works with arrays as well right?
@SMondalYT
@SMondalYT 6 лет назад
sir, How can I store the content of the localstorage into simple os files, or is it stored somewhere else ?
@dcode-software
@dcode-software 6 лет назад
Hey there, what do you mean by "Simple OS files"? If you mean files about the Operating System, you'd be unable to save to locally to the disk
@SMondalYT
@SMondalYT 6 лет назад
I have a javascript file running in the local server. When I write "console.log(data)" its printing the data in the console , but I need that data to access in matlab anyhow
@dcode-software
@dcode-software 6 лет назад
If you're running a Node server you should be able to simply write the contents of local storage (wherever it may come from) to the disk. Otherwise I'm not entirely sure what the question is 😥
@zainazam3438
@zainazam3438 3 года назад
I have stored values in local storage..How can I get that values on the form back?
@kacperkepinski4990
@kacperkepinski4990 2 года назад
How to push objects to storage when i create them dynamically
@apnaelectronics8916
@apnaelectronics8916 Год назад
there is a problem when I store second object it replaces first object may I know reason?
@yangus2485
@yangus2485 Год назад
i made same things but my console says: localStorage is not defined...why?
@421prateek
@421prateek 4 года назад
amazing video.. can i store images in local storage??
@ansara4729
@ansara4729 4 года назад
tnx man
@dcode-software
@dcode-software 4 года назад
No worries mate!
@Packword
@Packword Год назад
Why Do You Use LIGHT MODE
@user-kh6rp6yx1j
@user-kh6rp6yx1j 5 месяцев назад
Hey, good.
@jamesknight2382
@jamesknight2382 3 года назад
What if you have an array with a few objects in it and you only want to store one of the objects in the array?
@dcode-software
@dcode-software 3 года назад
Easy, just grab the object via index such as [2]
@jamesknight2382
@jamesknight2382 3 года назад
@@dcode-software so what if you had buttons on the page and you wanted them to be allocated to storing different parts of the array?
@AG-qp7gn
@AG-qp7gn 3 года назад
I would kiss you If I could, Great Tutorial!
@Jason06245
@Jason06245 2 года назад
This is very helpful than you.
Далее