04
Apr 08

JavaScript parseInt and parseFloat functions

If the Number() function was generic in nature then the parseInt() and parseFloat() functions will act to be more specific in what they do.

parseInt() will parse the data into an integer value(if possible) and return the result. It returns ‘NaN’ i.e. ‘Not a Number’ if the data is unparseable.

Similarly, parseFloat() parses float values.

Here are a few examples to help you understand these two functions better:

var a = “10″;

alert(parseInt(a));

alert(parseFloat(a));

output:

10

10

a = “10.12″;

alert(parseInt(a));

alert(parseFloat(a));

output:

10

10.12

a = ” 10.25 as you can see, white spaces are allowed and also alphabets after the number”

alert(parseInt(a));

alert(parseFloat(a));

output
:

10

10.25

a = ” nope this is wrong, wont work 100.24″;

alert(parseInt(a));

alert(parseFloat(a));

output
:

NaN

NaN


01
Apr 08

‘indexOf’ or ‘contains’ function for Javascript

The thought of elaborating on the “contains” function for JavaScript occurred to me while I was writing my previous post . From what I know, JavaScript doesn’t seem to have a function to allow the user to check if a particular letter exists in the given data.

But, it does have an indexOf() function that might just do the trick :)

All you need to do is check whether the return value is -1 or not. A return value of -1 implies that the specific letter is not present in the given data.

A simple example below will make things clear:

function checkIndexOf()
{
var a = “hello”;

alert(a.indexOf(‘l’));
alert(a.indexOf(‘E’));
alert(a.indexOf(’0′));

}

The output is as follows:

2 // which implies that the letter ‘l’ is present in position 2.

-1 //which implies that the letter ‘E’ is not present.(JavaScript is case sensitive)

-1 //which implies that the number 0 is not present.


01
Apr 08

The next killer app!!!

A relatively unknown company in a small town named lirpa
loof seemed to have come out with a software that supposedly does the programming all by itself!! Yeah, you heard it right. I too couldn’t believe it myself until I saw the demo!!

Analysts call it the invention of the new century. Andy, one of the first few allowed to have a dekko at the software had to say this – “It’s an amazing tool they’ve developed!! To check it myself, all I did was type the sentences – ‘Table, three column, one row, add dynamic row’ and woh!! In just 28 secs the tool was ready with the appropriate JavaScript!!! No one will ever need to learn to code from now on. Everyone’s a programmer with this tool.”

Researchers all over the world have been trying to come out with an app like this for years but with no luck. Ripal, the CEO of the company which developed this killer app went on to say that with this tool, even kids in kindergarten would be able to come out with their own softwares!!

But as every great invention has its own cons, scientists all over the world expressed concern saying that this would deter people from becoming software professionals as their job would be made absolete with this tool!!

Hmmm… I know, I know. You must be eager to have a go at the software yourself like the way I was eager to. I managed to get the name of the software through my reliable sources and googled it to get a preview. You too can do the same. The name is just the reverse of the name of the place where the software was developed – Lirpa Loof.

Or, should I say april fool . Go spread the word. Let the world know about the next killer app. Send this link (http://techtamasha.com/?p=41) to all your friends.