M
M
magicrushheroes2016-07-06 14:01:30
JavaScript
magicrushheroes, 2016-07-06 14:01:30

What are the differences between localstorage and cookies?

What are the pros and cons of one and the other and when to use cookies and when to use localstorage?
There is also a question: if we write setInterval 2000, then one hundred percent will be called what is inside the setinterval, after 2000 milliseconds, or is there some kind of exception?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2016-07-06
Protko @Fesor

There is also a question: if we write setInterval 2000, then one hundred percent will be called what is inside the setinterval, after 2000 milliseconds, or is there some kind of exception?

100% which is not earlier than in 2000 milliseconds but can be much later. For example:
setTimeout(function () {
    console.log('Hi from past');
}, 500);

while(true) { }

in the example above, the function will never be called because .... an infinite loop simply will not allow you to move on to another piece of tasks. To understand why this is so, we read about the event loop.

A
Alexey Samsonov, 2016-07-06
@forevist

About intervals, I advise you to watch this video
and if you search, you can find his site used in his report

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question