About javascript console.time ()?

console.time () and console.timeEnd () can print the execution time of the program.

(function(){
    console.time("index");
    var div = document.getElementById("div");
    div.onclick = function(){
        alert("123");
    };
    console.timeEnd("index");
}());

question: why is the time printed when it is not clicked?


because div.onclick = function () {.} is just an assignment operation.

in your code, console.time only counts the time taken by
var div =. (ignoring the behavior of getBy. , simplifying the problem)
div.onclick =.
these two assignment operations.


console.timeEnd ('index'); not in the click event. The click event in


code only executed alert (' 123');

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35514-2bf89.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35514-2bf89.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?