typeof operator- typeof null-a known bug in javascript As per ECMAscript5 specifications Javascript has 5 primitive data-types. number string boolean undefined null We all know that Javascript is loosely typed, a Javascript variable holding a particular type of value can hold another type of value at another point of time. So, interrogating Javascript variables and values is a very handy ... Read More »
Tag Archives: javascript
Difference between undefined and null in Javascript- When to use what?
Difference between undefined and null in Javascript- When to use what? This is one of the most confusing topics in the Javascript world. Beginners finds it difficult to understand when to use what. Kindly read my below post for understanding undefined. Understanding undefined in Javascript Null is like N/A(not applicable). It’s a non-value, nothing. Both undefined and null indicates absence ... Read More »
Understanding undefined in Javascript
Understanding undefined in Javascript Interesting thing about variable handling in Javascript is there is no type information associated to a variable. Ex, var anoop=1; Here variable anoop is of number type. But, since Javascript has loose typing so we can associate anoop variable to string type. anoop="hello javascript"; What I wanted to say is in Javascript variable can be associated ... Read More »
Number primitive type in Javascript
Number primitive type in Javascript As with any other language Javascript comes loaded with its primitive types. As per ECMAscript5 Javascript has number primitive type for dealing with integers, floating-points, double, long. Well these are some fantasies of JAVA world(which depends on the precision of the number you want), but almost every language has these characteristics. Javascript don’t care about ... Read More »
What is javascript? Why to use javascript?—- Buzzwords explained with simplicity
What is javascript?—- Buzzwords explained with simplicity Javascript is the one of most misunderstood language as per Douglas crockford(a famous name in the Javascript world). There will be times when you will love this language the most as well hate it as much as you can. Now lets come to the point, as per Mozilla Developer Network, JavaScript (often shortened ... Read More »
Javascript for loop vs jQuery for each
Javascript for loop vs jQuery for each Web developers often come across looping through data at client side. People generally use native Javascript coding for loop, or jQuery for each. Javascript For Loop. Example var names= ["anoop", "kumar", "rai"]; var i; var text=""; for (i = 0; i < cars.length; i++) { text += names[i] + ","; } document.write(text); Result-> ... Read More »
Detecting key press for input text and Detecting Enter key
Detecting key press for input text and Detecting Enter key The order of events related to the keyup event: 1. keydown – The key is on its way down 2. keypress – The key is pressed down 3. keyup – The key is released The keyup event occurs when a keyboard key is released. The keyup() method triggers the keyup ... Read More »
Prevent Safari/any browser loading from cache when back button is clicked
Prevent Safari/any browser loading from cache when back button is clicked This problem is caused by back-forward cache. It saves complete state of page when user navigates away. When user navigates back with back button, page is loaded from cache very quickly. This is different from normal cache which only caches HTML code. This kind of situation arises mainly with ... Read More »
jQuery detecting scroll- scroll reaching to the bottom of page
jQuery detecting scroll- scroll reaching to the bottom of page Detecting scroll and executing login based on scrolling has important significance in web development like implementing pagination, where more data gets loaded when user scrolls near the bottom of page. So, first basic question arises as to how to detect scroll. window.onscroll = function(ev) { //execute your logic here } ... Read More »
Using strict mode to write secure Javascript
Using strict mode to write secure Javascript We know that doing read operation from undeclared variable gives error in Javascript, whereas doing write operation to an undeclared variable is fine and the variable gets the global scope (I will discuss this in a different post as to why this happens in Javascript). Now, lets take stock of a situation in ... Read More »