Home » Javascript

Power of javascript closure

Closure

It is a advance concept of javascript. This is really interesting concept in javascript. So basically it is a function inside function which can access outer function properties. According to MDN “A closure is the combination of a…

Read More »

Javascript ninja secrets

ninja_secrets

It’s all about js cool tips and tricks which help day to day programming and reduce the time of the developer. For more tricks you can also read Tips and Tricks. 1. Use == instead of === ==…

Read More »

Regular expressions

regex

It is a powerful way of searching and replacing something inside a string. To implement that we can use RegExp class and integrated with strings. In Regular expressions we need pattern and optional flags. So we have 2…

Read More »

for…of

for...of

for-of is a new loop in ES6 that replaces both for-in and forEach() and supports the new iteration protocol. Use it to loop over iterable objects (Arrays, strings, Maps, Sets, etc.; see Chap. “Iterables and iterators”) Syntax for…

Read More »

Template strings

template_string

String Interpolation String Interpolation is the way by which we can insert variable into string. In Javascript We have two type for String Interpolation. 1. Traditional 2. ES6 1. Traditional Way In traditional Javascript, string always encolsed within…

Read More »

Destructuring

destructuring

Destructuring Destructuring is a way to quickly extract data out of an {} or [] without having to write much code. ES5 Way let foo = [‘x’, ‘y’, ‘z’]; let a = foo[0]; let b = foo[1]; let…

Read More »

Basic javascript algorithms

js algorithms

Get uniq from array // get uniq from array const nums = [1, 2, 1, 1, 2, 1, 3, 4, 1 ]; const uniq = […new Set(numbers)]; // => [ 1, 2, 3, 4 ] const uniq2 =…

Read More »

JSON, n JSON method

json

The JSON (JavaScript Object Notation) is a general format to represent values and objects. JSON is the string form of object. Syntax: JSON.stringify(value[, replacer[, space]]) Parameters: Value The value to convert to a JSON string. Replacer Optional The…

Read More »

ES6 arrow functions

es6 arrow function

Arrow function taken from CoffeeScript (a transcompiled language). Arrow function, also called “fat arrow” functions. This is represented by => (Flat Arrow). It is anonymous and can change the way this bind into function. When we are using…

Read More »

Javascript function arguments handling

arguments

In javascript we don’t have any method to check our parameters and arguments. Earlier tutorial, We have learned that functions can have parameters; like – functionName(parameter1, parameter2, parameter3) { code to be executed } but suppose that we…

Read More »