var timeoutId = setTimeout(function() {
alert('5 seconds passed');
}, 5000);
var intervalId = setInterval(function() {
console.log(new Date());
}, 1000);
clearTimeout(timeoutId);
claerInterval(intervalId);
requestAnimationFrame(callback);
//Non-standard
var immediateID = setImmediate(func, [param1, param2, ...]);
{
assign: function(),
hash: "locationInfo",
host: "developer.mozilla.org",
hostname:"developer.mozilla.org",
href: "https://somesite.org/Window/location?v=1#locationInfo",
origin: "https://somesite.org",
pathname: "/Window/location",
port: "",
protocol: "https:",
reload: function(),
replace: function(),
search:"?v=1"
}
//changing page
location.assign("http://www.anothersite.org"); // or
location = "http://www.anothersite.org";
//reload page
location.reload(true); //or
location.assign(location.href); //or
location.replace(location.href);
{
length: 4,
pushState: function(),
replaceState: function(),
scrollRestoration: "auto",
state: null
}
history.back(); // equivalent to clicking back button
history.go(-1); // equivalent to history.back();
window.onerror = function(msg, url, line) {
if (onerror.num++ < onerror.max) {
alert('ERROR ICCURED: ' + msg + ', at ' + url + ':' + line);
return true;
}
};
onerror.max = 3;
onerror.num = 0;
// prefer
try {
//code which may cause erorr
} catch (e) {
//handle error
} finally {
//perform finallization
}
var windowObjectReference = window.open(strUrl, strWindowName, [strWindowFeatures]);
var result = window.showModalDialog(
'dialog.html',
'Dialog Window',
'dialogwidth: 400px; dialogheight:200px; resizable:no'
);
<html>
<head>
<title>
Window Element Properties
</title>
</head>
<body>
<div id="mainTextBlock"> Lorem Ipsum Dolor Sit Amet </div>
<script type="text/javascript">
console.log(window.mainTextBlock);
</script>
</body>
<html>
window == self;
window.top;
window.parent;
window.frames;
window.frames[0].contentWindow;
Basically there are two main kinds of JavaScript at client-side
JavaScript in Web Documents
JavaScript in Web Application
JavaScript in Web Documents
JavaScript in Web Application
<html>
<head>
<script src="https://code.jquery.com/jquery-2.2.3.js"
integrity="sha256-laXWtGydpwqJ8JA+X9x2miwmaiKhn8tVmOVEigRNtP4="
crossorigin="anonymous">/* JQuery CDN */</script>
<script defer src="app/main.js">/* Main application module import */</script>
<script async src="app/utils.js">/* Utility functions */</script>
<script src="app/body-parser.js">/* Analyzer module */</script>
</head>
<body>
<h1>How it's look like</h1>
</body>
</html>
document.readyState == 'loading';
document.readyState == 'interactive';
DOMContentLoaded event fired on Document object
document.readyState == 'complete';
Feature Testing
Graded Browser Support
Compat Libraries
Quirks Mode
Browser Testing
Can I Use
IE...