4 Notepad++ Plugins for Javascript Developers

Editor’s Note: This post is from 2012. The hottest editors in 2018 are vscode and editor.

Here are some Notepad++ plugins for JavaScript Developers that I found useful.

Tip:
You can install all the plugins using Notepad++ Plugins Manager located in the “Plugins” Menu.

  1. JSLint


    Description:
    JSLint is a static code analysis tool used in software development for checking if JavaScript source code complies with coding rules.


    Tip:
    If jslint turns out to be strict for you, then I recommend that you try jshint.com.
    Does it make any sense to use JSLint and follow it?

  2. JSMin


    Description:
    JSMin is a filter which removes comments and unnecessary whitespace from JavaScript files.


    Tip:
    The great thing about this plugin is that it formats and minimizes.
    Link:
    JavaScript Compressor and Comparison Utility.

  3. JSON Viewer


    Description:
    A JSON viewer plugin for Notepad++. Displays the selected JSON string in a tree view.


    Tip:
    If you get “Could not parse!!” error message, then reformat your code with JSON.stringify().

  4. RegEx Helper


    Description:
    A Notepad++ plugin that allows users to develop regular expressions and test them against their open documents.

Code of the day: Get unique objects from an array of json objects.


Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/bateeqjg/public_html/news/wp-content/plugins/wp-syntax/wp-syntax.php on line 380

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/bateeqjg/public_html/news/wp-content/plugins/wp-syntax/wp-syntax.php on line 380

Inspired from Removing duplicate objects with Underscore for Javascript

Source:

/**
@function _.uniqObjects
@require Underscore.js and json.stringify
@purpose return an array of objects without duplicated objects.
*/
_.uniqObjects = function( arr ){
	return _.uniq( _.collect( arr, function( x ){
		return JSON.stringify( x );
	}));
};

Example:

var foo = [ { "a" : "1" }, { "b" : "2" }, { "a" : "1" } ];
_.uniqObject( foo );  // returns [ { "a" : "1" }, { "b" : "2" } ]

Reimplementation of Number.prototype.toFixed


Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/bateeqjg/public_html/news/wp-content/plugins/wp-syntax/wp-syntax.php on line 380

Number.prototype.toFixed was giving me too many problems, so I just rewrote it.
There’s the source.

/**
@author Larry Battle <a alt="contact me" href="bateru.com/news/contact">Contact Me</a>
@date	Mar 30, 2012
@purpose Provide the fix for Number.prototype.toFixed() function.
@info source at http://bateru.com/news/2012/03/reimplementation-of-number-prototype-tofixed
 */
Number.prototype.toFixed_fix = function (precision) {
	var num = this.toString(), zeros = '00000000000000000000', newNum, decLength, factor;
	if (0 > precision || precision > 20) {
		throw new RangeError("toFixed() digits argument must be between 0 and 20");
	}
	if (Math.abs(num) === Infinity || Math.abs(num) >= 1e21) {
		return num;
	}
	precision = parseInt(precision, 10) || 0;
	newNum = num = isNaN(parseInt(num, 10)) ? '0' : num;
	if (/\./.test(num)) {
		decLength = num.split('.')[1].length;
		if (decLength < precision) {
			newNum += zeros.substring(0, precision - decLength);
		} else {
			factor = Math.pow(10, precision);
			newNum = Math.round(num * factor) / factor;
		}
	} else {
		if (precision) {
			newNum += '.' + zeros.substring(0, precision);
		}
	}
	return newNum;
};

Test cases here

Want to learn more about Javascript?
Checkout this ‘Professional JavaScript for Web Developers’.