This post is a part 18 of ECMAScript 6 Complete Tutorial post series. Object reflection is an language ability to able to inspect and manipulate object properties at runtime. JavaScript already had been supporting APIs for object reflection but these APIs were not organized under a namespace and also they threw exception when they fail […]
Here is the code that can generate a unique number in JavaScript. function uniqueNumber() { var date = Date.now(); if (date <= uniqueNumber.previous) { date = ++uniqueNumber.previous; } else { uniqueNumber.previous = date; } return […]
Although your JSON string is valid JSON.parse is likely to throw error. This is because JSON.parse cannot parse some special characters that are \n, \t, \r and \f. You need to escape these special characters for before passing JSON string to JSON.parse function. Here is a function that takes a JSON string and escapes the […]
AngularJS is suitable for creating AJAX based dynamic applications and applications which require a lot of DOM content manipulations. For example: AngularJS is the best way for creating single app websites. AngularJS helps you to build such kinds apps with less code and more flexibility. Example Here is an AngularJS example app which covers almost […]
Here are example codes showing how to make a basic GET and POST request using XMLHttpRequest object GET Request using XMLHttpRequest Here is an example which works on all devices and browsers var request; if(window.XMLHttpRequest) { request = new XMLHttpRequest(); } else if(window.ActiveXObject) { try { request = new ActiveXObject(’Msxml2.XMLHTTP’); […]
AJAX websites tend to be much faster as it’s about updating parts of a web page, without reloading the whole page. AJAX lets web pages to update asynchronously by retrieving data from server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page. But […]
By default desktop browsers let you scroll an element or page using the mouse wheel. But its unfriendly when users want to scroll both horizontally and vertically. Mouse wheel doesn’t seem to be the best option in that case. Therefore we can let users scroll by holding the mouse button i.e., dragging. For example, Google […]
Number counter animation is used throughout the web to display numbers in a more interesting and eye-catching way. For example: Websites use number counter animations to display total number of shares and views of an article. In this tutorial I will show you the easiest way to create such animation using JavaScript. countUp.js Library We […]
Facebook loads new posts on timeline and news feed as you scroll down. This makes Facebook home page and profile load faster as Facebook don’t have to load everything on page load. For achieving this Facebook uses a technique called as Infinite scrolling. In this tutorial we will see how to achieve infinite scroll using […]
Most Commented