Removing an Item from Javascript Array | JavaScript Array pop() Method Example | JavaScript Tutorial

The pop() method removes the last element of an array, and returns that element. pop() method also changes the length of an array after removing the last element.

var fruits = ["Banana""Orange""Apple""Mango"];

The result of fruits will be:


JavaScript Regex Quick Reference | JavaScript Regular Expression Quick Reference

The below tables serves as a quick reference for JavaScript regular expression.

Regular Expression Basics
.Any character except newline
aThe character a
abThe string ab
a|ba or b
a*0 or more a's
\Escapes a special character

Regular Expression Quantifiers
*0 or more
+1 or more
?0 or 1
{2}Exactly 2
{2, 5}Between 2 and 5
{2,}2 or more

Regular Expression Groups
(...)Capturing group
(?:...)Non-capturing group
\YMatch the Y'th captured group

Regular Expression Character Classes
[ab-d]One character of: a, b, c, d
[^ab-d]One character except: a, b, c, d
[\b]Backspace character
\dOne digit
\DOne non-digit
\sOne whitespace
\SOne non-whitespace
\wOne word character
\WOne non-word character

Regular Expression Assertions
^Start of string
$End of string
\bWord boundary
\BNon-word boundary
(?=...)Positive lookahead
(?!...)Negative lookahead

Regular Expression Flags
gGlobal Match
iIgnore case
m^ and $ match start and end of line

Regular Expression Special Characters
\rCarriage return
\0Null character
\YYYOctal character YYY
\xYYHexadecimal character YY
\uYYYYHexadecimal character YYYY
\cYControl character Y

Regular Expression Replacement
$$Inserts $
$&Insert entire match
$`Insert preceding string
$'Insert following string
$YInsert Y'th captured group

Getting Query String Values using JavaScript or jQuery | JavaScript Tutorial | JavaScript Programmer Guide

We can easily get the query string value by accessing the window.location in JavaScript. The below code snippet provides a JavaScript function that reads the query string parameter password to the function

01function GetQueryStringParams(sParam)
03    var sPageURL =;
04    var sURLVariables = sPageURL.split('&');
05    for (var i = 0; i < sURLVariables.length; i++)
06    {
07        var sParameterName = sURLVariables[i].split('=');
08        if (sParameterName[0] == sParam)
09        {
10            return sParameterName[1];
11        }
12    }

Considering below Url as an example,

You can simply call the JavaScript function below by passing the query string variable name:

2var tech = GetQueryStringParams('technology');
3var blog = GetQueryStringParams('blog');

Responsibilities of Controllers in Angularjs | Angularjs Interview Question | Angularjs Tutorial | Angularjs Programmer Guide

Angularjs works on model-view-controller pattern. Angularjs Controllers have three responsibilities in your app:

  1. Set up the initial state in your application’s model
  2. Expose model and functions to the view (UI template) through $scope
  3. Watch other parts of the model for changes and take action

Creating Class in JavaScript | Simulating Classes Using Function in JavaScript | JavaScript Programmer Guide | JavaScript Tutorial

 JavaScript is a class-less language, however classes can be simulated using functions. The most common approach to achieving this is by defining a JavaScript function where we then create an object using the new keyword. this can be used to help define new properties and methods for the object as follows:

// A car 'class'
function Car(model) {
   this.model = model;
   this.color = 'silver';
   this.year = '2012';
   this.getInfo = function () {  
       return this.model + ' ' + this.year;

We can then instantiate the object using the Car constructor we defined above like this:

var myCar = new Car('ford');
myCar.year = '2010';

Programmatically Creating Script Element | Creating Script Element Programmatically

Considering some techniques to load scripts in parallel so that the overall download time becomes the longest of all instead of the sum of all downloads. The simplest way you can do this is through a programmatically created <script> element. You do this using code, as shown below.
var h = document.getElementsByTagName("HEAD")[0];
var script = document.createElement("script");
script.type = "text/javascript";
script.onreadystatechange = function() {...};
script.onload = function() {...};
script.onerror = function() {...};
document.src = "...";
Script elements are appended to the HEAD element so that parallel download begins as soon as possible. Note that this is the approach that most social Web sites and Google Analytics use internally. The net effect is that all dynamically created elements are processed on different JavaScript threads. This approach is also employed by some popular JavaScript loader frameworks these days.