// Save data to sessionStoragesessionStorage.setItem('key','value');// Get saved data from sessionStorageletdata=sessionStorage.getItem('key');// Remove saved data from sessionStoragesessionStorage.removeItem('key');// Remove all saved data from sessionStoragesessionStorage.clear();
The Window interface represents a window containing a DOM document
1234
// 跨頁面同步資料, 透過 listen 'storage' 是否改變去做同步window.addEventListener('storage',function(e){// Will fire for localStorage changes that come from a different page})
consttodo={id:'ididididididid',text:'Pay the bills',completed:false}const{text:todoText,completed,details='No details provided',...others}=todoconsole.log(todoText)// "Pay the bills"console.log(completed)// falseconsole.log(details)// "No details provided"console.log(others)// { id: "ididididididid" }
In function arguments
123456789
consttodo={id:'asdfpoijwermasdf',text:'Pay the bills',completed:false}constprintTodo=({text,completed})=>{console.log(`${text}:${completed}`)}printTodo(todo)