JavaScript ile LocalStorage Kullanımı

JavaScript ile LocalStorage Kullanımı

NBK BARIS2 Mayıs 2026JavaScript, Web-Tasarim

LocalStorage, tarayicida veri saklamanin en kolay yoludur. Sayfa yenilense bile veriler kaybolmaz!

Temel Kullanim

// (c) CodeMareFi - codemarefi.com.tr

// Veri kaydet
localStorage.setItem('kullanici', JSON.stringify({ isim: 'NBK BARIS', site: 'CodeMareFi' }));

// Veri oku
const kullanici = JSON.parse(localStorage.getItem('kullanici'));
console.log(kullanici.isim); // NBK BARIS

// Veri sil
localStorage.removeItem('kullanici');

// Tum verileri temizle
localStorage.clear();

Tema Tercihi Kaydetme

// (c) CodeMareFi - codemarefi.com.tr
function temaDegistir(tema) {
  localStorage.setItem('tema', tema);
  document.body.className = tema;
}

// Sayfa yuklendiginde temay uygula
const kayitliTema = localStorage.getItem('tema') || 'karanlik';
document.body.className = kayitliTema;
© CodeMareFi Bu icerik codemarefi.com.tr ye aittir.

0 Yorum

YORUM YAPMAK İÇİN SİSTEME SIZMANIZ GEREKİYOR

Lütfen yukarıdaki butonu kullanarak giriş yapın veya kimlik oluşturun.

Yorumlar yükleniyor...