Blog

JavaScript Snippet – suffixFileSize()

If you would like to convert the amount of bytes (or bits) into the corresponding measure when the size is a kilobyte or bigger (or a kilobit or bigger) you can use the following JavaScript function: Here are some examples of using it: // Convert bytes console.log(suffixFileSize(1023)); // 1023 B Read more…

By Chris West, ago
Blog

JavaScript Snippet – isValidVarName()

Now Available in YourJS Recently I was working on a function which needed to determine whether or not a string could be used as a variable name. Variable name validation can get tricky so instead of using a crazy regular expression which includes all keywords (which may change over time) Read more…

By Chris West, ago