diff options
author | ven <vendethiel@hotmail.fr> | 2015-10-19 23:01:13 +0200 |
---|---|---|
committer | ven <vendethiel@hotmail.fr> | 2015-10-19 23:01:13 +0200 |
commit | b354013dc9bcba5e76bd3cf720eae8af7d9eba89 (patch) | |
tree | 42081148c00996b045072e83c900a623f20a1664 /javascript.html.markdown | |
parent | f4c1f3d9475167c6c6447b6bdac54104d92e6515 (diff) | |
parent | 7fdce9215acde388da6de41f524aefa8bfb05532 (diff) |
Merge pull request #1659 from xssc/patch-2
[javascript/en] Added setInterval
Diffstat (limited to 'javascript.html.markdown')
-rw-r--r-- | javascript.html.markdown | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/javascript.html.markdown b/javascript.html.markdown index d408e885..a119be88 100644 --- a/javascript.html.markdown +++ b/javascript.html.markdown @@ -291,12 +291,9 @@ myFunction("foo"); // = "FOO" // Note that the value to be returned must start on the same line as the // `return` keyword, otherwise you'll always return `undefined` due to // automatic semicolon insertion. Watch out for this when using Allman style. -function myFunction() -{ +function myFunction(){ return // <- semicolon automatically inserted here - { - thisIsAn: 'object literal' - } + {thisIsAn: 'object literal'} } myFunction(); // = undefined @@ -310,6 +307,12 @@ setTimeout(myFunction, 5000); // Note: setTimeout isn't part of the JS language, but is provided by browsers // and Node.js. +// Another function provided by browsers is setInterval +function myFunction(){ + // this code will be called every 5 seconds +} +setInterval(myFunction, 5000); + // Function objects don't even have to be declared with a name - you can write // an anonymous function definition directly into the arguments of another. setTimeout(function(){ |