JavaScript: Literal Initialiser [] vs Constructor new Array() for Creating Arrays

The [] method is an array literal/array shorthand to initialise the array. The syntax is simple: a comma-separated list of values in square brackets []

The new Array() method is to create an instance by calling the array constructor. The new Array() syntax has three different forms: If you call the constructor with TWO […]

Continue reading


JavaScript: Alternative method for HTML 5 Data Attribute in Old Browsers

The HTML5 datalist property is not available in older browsers (it can be polyfilled easily enough though). The standard getAttribute method can be used instead of course, and data-xxx attributes on HTML elements are accepted by all browsers, IE also has supported this method from IE4. Sample HTML

JavaScript

Continue reading


JavaScript Query String Getting and Parsing to Object with Regular Expression

What is Query String Query string is the part of a uniform resource locator (URL) containing data that does not fit conveniently into a hierarchical path structure. It commonly includes fields (requested pairs of key and value) added to a base URI by a Web browser or other client application, for example

The first […]

Continue reading


jQuery Access Internal Event-related Data through _data() method

jQuery internally stores and maintains the list of events which was attached or detached from DOM elements. Meanwhile, jQuery data mechanism jQuery._data() – the “undocumented” method – which allow us to access the jQuery internal event-related data structure. As of jQuery 1.8, the event data is no longer available from the “public API” for data. […]

Continue reading