4

If 4e3 is equal to 4 seconds. What would I use for 3 Secs? or 2 Secs?

<SCRIPT LANGUAGE="javascript">
$( function() {
 setTimeout(function() {
        $('#loadingque').trigger('click');
    }, 4e3);
});
</script>
user1824806
  • 65
  • 1
  • 2
  • 8

4 Answers4

17

If you understand why 4e3 is 4000 then you can figure out what 3000 looks like. eN means 10 to the power N, so 3 times 10 to the power 3 is 3000, or 3e3.

elclanrs
  • 92,861
  • 21
  • 134
  • 171
  • 1
    Note that it's also possible to have negative powers of `N`, so `1e-1 === 0.1`. I think there's a sort-of-convention for always including the sign, so really you should use `3e+3` not `3e3`. – RichardTowers Nov 15 '12 at 09:08
  • Never heard of such convention (at least in JS). Don't see how that can be useful tho, I mean `+` in front of a positive number means nothing, and `3e-3` is easy enough to spot. – elclanrs Nov 15 '12 at 09:10
  • @broox I encountered this notation in minified javascript files. I think it makes sense there. It's shorter to write 4e3 than 4000. – dkns May 11 '17 at 13:51
2
setTimeout(function() {
      // Do something after 5 seconds
}, 5000);

jQuery(document).ready(function () {`enter code here`
    //hide a div after 3 seconds
    setTimeout( "jQuery('#div').hide();",3000 );
});

Hope these will help u..

Pravin Kumar
  • 693
  • 1
  • 9
  • 35
2

It takes milliseconds

setTimeout(function() {
    document.write(new Date());
}, 3000);
Ziem
  • 6,579
  • 8
  • 53
  • 86
Akhil Sekharan
  • 12,467
  • 7
  • 40
  • 57
0
var runCount = 0;
var maxCount = 1000000;

function timerMethod()
{
    runCount++;
    if(runCount >= maxCount)
    {
        clearInterval(timerId);
    }
    $('#loadingque').trigger('click');
    console.log(runCount + "of" + maxCount);
}

var timerId = setInterval(timerMethod, 3000);

this is running every 3000ms for maxCount times

ddarellis
  • 3,912
  • 3
  • 25
  • 53