Category Archives: JavaScript

PHPHOST BLOG

Web Hosting Related Articles You May Need

Swap Variables in JavaScript – Different Methods

Here are some different ways to swap variable values in JavaScript. I will show swapping using a temporary variable, without a temporary variable, XOR operator and a single line swap.
Swap variable values using a temporary variable

// Using a Temp Var… Continue reading

Posted in JavaScript, Syndicated | Leave a comment

Conditional CSS and JavaScript for Different Browsers

A common technique adopted by developers is to detect browsers and conditionally differentiate CSS rules and JavaScript for specific versions of browsers. In simple words, a requirement could be that if the browser is IE, use a different set of CSS and… Continue reading

Posted in JavaScript, Syndicated | Leave a comment

Conditional CSS and JavaScript for Different Browsers

A common technique adopted by developers is to detect browsers and conditionally differentiate CSS rules and JavaScript for specific versions of browsers. In simple words, a requirement could be that if the browser is IE, use a different set of CSS and… Continue reading

Posted in JavaScript, Syndicated | Leave a comment

JavaScript: Convert CamelCase to Dashes and vice-versa

My colleague Satyam shared a nice piece of JavaScript code that converts a camelcase to dashes and dashes to Camelcase.
For eg: if the string has a camelcase in it – like ‘viceVersa’, the result expected is ‘vice-Versa’. Similarly if a string h… Continue reading

Posted in JavaScript, Syndicated | Leave a comment

JavaScript: Convert CamelCase to Dashes and vice-versa

My colleague Satyam shared a nice piece of JavaScript code that converts a camelcase to dashes and dashes to Camelcase.
For eg: if the string has a camelcase in it – like ‘viceVersa’, the result expected is ‘vice-Versa’. Similarly if a string h… Continue reading

Posted in JavaScript, Syndicated | Leave a comment

Unary plus operator in JavaScript

The unary plus (+) operator is a unary operator and converts its operand to a number, if it isn’t already. It is equivalent to the Number() constructor called as a function. Let us see some examples of the Unary + operator and what does it imply in d… Continue reading

Posted in JavaScript, Syndicated | Leave a comment

Unary plus operator in JavaScript

The unary plus (+) operator is a unary operator and converts its operand to a number, if it isn’t already. It is equivalent to the Number() constructor called as a function. Let us see some examples of the Unary + operator and what does it imply in d… Continue reading

Posted in JavaScript, Syndicated | Leave a comment

JavaScript Object can have Private Methods

I was watching a JavaScript video tutorial by Douglas Crockford where he explained private members in JavaScript. Although there are no ‘private methods’ in a JavaScript object, we can easily create something similar by defining a function variable… Continue reading

Posted in JavaScript, Syndicated | Leave a comment

JavaScript Object can have Private Methods

I was watching a JavaScript video tutorial by Douglas Crockford where he explained private members in JavaScript. Although there are no ‘private methods’ in a JavaScript object, we can easily create something similar by defining a function variable… Continue reading

Posted in JavaScript, Syndicated | Leave a comment

Array Shuffle in JavaScript

I have yet to find a script that truly does a random shuffle across all browsers using JavaScript (no frameworks). However there are a couple of scripts I use, that are ‘good-enough’ to be used when an Array has to be shuffled. One of them which wo… Continue reading

Posted in JavaScript, Syndicated | Leave a comment