관리 메뉴

Silver Library (Archived)

JavaScript - DB, class/function, countdown, adding keyword 본문

Personal DB/Unclassified record

JavaScript - DB, class/function, countdown, adding keyword

Chesed Kim 2021. 9. 12. 19:48
반응형

localStorage.setItem(USERNAME_KEY, username); // Registering the input value to its localStorage DB(API). - setItem
// const USERNAME_KEY = "username";
// const username = loginInput.value; //
// const loginInput = document.querySelector("#login-form input");

document.querySelector
// The querySelector() is a method of the Element interface. 
// The querySelector() allows you to find the first element that matches one or more CSS selectors.


setInterval(test, 2000); => 'test' will appear in 2 secs on the console screen once page loading is complete.

setTimeout(test, 2000); => vice versa.

*note: key difference is; setInterval will repeat this process infinitely. So setTimeout is the one to end it.

 

.padStart is kind of unique way trigger some action.

if clock's seconds displays 0, 1, 2, ...9, 10; then stringify that object's following code.

and then, .padStart(2, "0");

Then it will display as 00, 01, 02.

be advised: to make it as of adding some specific string one conditionally, you must use prototype concept.

In this case, constructor is the one you should use to let it generates the number "0".