I am trying to start learning JavaScript instead of allways copying it. I know this probably is super simple, but where does Date() come from? Why can I call it?
<!DOCTYPE html>
<html>
<head>
<script>
function displayDate() {
document.getElementById("demo").innerHTML = Date();
}
</script>
</head>
<body>
<h1>My First JavaScript</h1>
<p id="demo">This is a paragraph.</p>
<button type="button" onclick="displayDate()">Display Date</button>
</body>
</html>
Date()is a built in object, declared in the global scope, just likeMath,Arrayetc.You can read more about this under section
4.2 Language Overviewin the ECMA specification. Quote: