Showing posts with label IE8. Show all posts
Showing posts with label IE8. Show all posts

Monday, December 9, 2013

Javascript - parseInt


If using latest version of browser can see parseInt("012345") giving number 12345 as output.
However, in some old browser, e.g. IE 8 , if the string parameter starts with a "0", it uses octal radix(8) to convert the string.
In IE 8, parseInt("012345") gives number 5349 as output, where it uses 8 as radix instead.

Sunday, December 8, 2013

Javascript - Array functions



var fruits = [ "apple" , "orange" , "lemon" , "berry"];
var fruits = new Array( "apple" , "orange" , "lemon" , "berry");
Both array instantiations are the same and correct, in which new Array(...) is a more formal way to do that.
Since Javascript is lose type language, it does not care the data type inside the array. Or even you could have a mixed data type with integer and string inside an array.

Thursday, December 5, 2013

Javascript - String functions



String.substr() VS String.substring() String.substr(start,length) is different from String.substring(start,end).
The second parameter length in substr() specify the number of character to be extracted,
whereas the second parameter end in substring() specify the index of ending character in the string.
Do not mess these two up. And pay attendion to the effect of negative number as second parameter giving to these functions.