Elementals.js

Latest Version: 2.0 RC 3 14 March 2017

Method String.pad

Summary:

Gets the vertical scroll of the current window.

Calling Convention:
String.pad(count[, character])
Parameters
count

The number of characters to pad the string by. If this value is positive the characters will be added to the end of the string. If negative they will be added to the beginning of the string. If the string is longer than this number, the returned string will be unchanged.

Note, if you pass a non-numeric value, this WILL throw an error.

character Optional
The character to be repeated. If omitted a space will be used. Should you pass a string longer than one character to this routine, only the first character of that string will be used!
Returns:
The new padded string result.

JavaScript

console.log(String('test').pad(8, 'x')); // 'testxxxx'
console.log(String('test').pad(-8, 'x')); // 'xxxxtest'

Downloads

Advertisement