Jump to content

!operand


Matej

Recommended Posts

hi.

Whats the diffrence between setTimeout and setInterval?

 

I mean , when i want to make slideshow setTimeout works but Setinverval doesnt , but both of them should work for that.

Edited by Matej
Link to comment
Share on other sites

The ! operator returns a boolean value that can be true or false.

!false is true, !true is false.

 

If the data type is not boolean it will be cast to boolean. All numbers are considered true except zero. All strings are true except an empty string.

If timer_is_on is 0, then !timer_is_on is true, if timer_is_on is any number other than 0 then !timer_is_on is false.

Link to comment
Share on other sites

Did you edit your question or something to ask something completely different? You shouldn't do that, just make a new post. Among other things, if you edit your question it doesn't let anyone know that there is a new unread post to look at.The only difference between setInterval and setTimeout is that using setTimeout will only run the code once after the certain amount of time, while setInterval will keep running the code after the interval until you stop it. Everything else works the same.

Link to comment
Share on other sites

hi.

Whats the diffrence between setTimeout and setInterval?

 

I mean , when i want to make slideshow setTimeout works but Setinverval doesnt , but both of them should work for that.

the difference is well documented in the tutorials

 

http://www.w3schools.com/jsref/met_win_setinterval.asp

 

The setInterval() method calls a function or evaluates an expression at specified intervals (in milliseconds).

 

The setInterval() method will continue calling the function until clearInterval() is called, or the window is closed.

 

http://www.w3schools.com/jsref/met_win_settimeout.asp

 

The setTimeout() method calls a function or evaluates an expression after a specified number of milliseconds.

 

 

Tip: The function is only executed once. If you need to repeat execution, use the setInterval() method.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...