Courtesy: A Javascript conference video. I forgot the name of the conference. Will update.
var name = 'Mr. Bond';
(function(){
if(typeof name === 'undefined'){
var name = "Mr. Bond";
sayHello(name);
} else {
alert(name);
...
Wednesday, December 18, 2013
JavaScript Puzzle - 1
Courtesy: A Javascript conference video. I forgot the name of the conference. Will update.
var END = 9007199254740992; //Math.pow(2,53)
var START = END - 100;
var count = 0;
for(var i = START; i<= END; i++){
count++;
}
alert(count);
What this alerts? And, give me the reason for that.
...
Tuesday, October 22, 2013
Browser rendering performance testing - document.createfragment vs jquery-element

After reading the post on browser rendering perforamnce, I tried some performance tests. You can see the test in the following url:
http://jsperf.com/document-createfragment-vs-jquery-element
See the chrome result. Doing with jquery element is faster than doing with document.createDocumentFragment....
Wednesday, October 16, 2013
Console is undefined error on console.log
I got error in my script on console.log('sample text'). Only possibility I could think of is I am adding this in IIFE. Is this could be an issue? I will post the udp...
Tuesday, October 1, 2013
Browser specific CSS Hacks
1. Webkit browser
@media screen and (-webkit-min-device-pixel-ratio:0) {
/* put your styles here */
}
2. IE8
use the \0/ attribute
.elementclass
{
width: 50px\0/; /* This will get only applied to IE8 */
}
3. IE7
use the *
.elementclass
{
*width: 50px; /* This will get only applied to IE7 */
}
4. IE9
using the :root attribute
:root .elementclass
{
/* this style will be applied to IE9 only...
Sunday, September 29, 2013
Web RTC Project in Backbone
2:24 AM
Posted by Unknown
backbone, ice candidate, icecandidate, peer, peer to peer, socket, stun, turn, webrtc, webrtc in backbone, websocket
1 comment
I have created a WebRTC project in backbone so that, the code will be easy to follow.
https://github.com/jintoppy/webrtc-backbone
All web rtc related functions are given in the webrtc-backbone / public / js / services / WebRTCService.js file...
Wednesday, September 18, 2013
Duff’s Device pattern in JavaScript
7:20 AM
Posted by Unknown
advanced JS, duff device, javascript, loops, performance improvement
No comments
Duff’s Device pattern in JavaScript
Duff’s Device is a technique of unrolling loop bodies so that each iteration actually does
the job of many iterations. Jeff Greenberg is credited with the first published port of
Duff’s Device to JavaScript from its original implementation in C. A typical implementation
looks like this:
//credit: Jeff Greenberg
var iterations = Math.floor(items.length / 8),
startAt...
Wednesday, September 11, 2013
My WebRTC experiments
I am trying on WebRTC. I will update my progress here. Currently, I am stuck on the following issue.
When I am using RTCDataChannel.send method, I am getting the following error:
Uncaught InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable.
I am checking if this is because of the createOffer issue.
Those who are not familiar with webRTC, you can...
Sunday, May 12, 2013
The superpowers of constructors
Invoking a function as a constructor is a powerful feature of JavaScript, because when a constructor is invoked, the following special actions take place:
A new empty object is created.
This object is passed to the constructor as the this parameter, and thus becomes the constructor’s function context.
In the absence of any explicit return value, the new object is returned as the constructor’s...
Scoping and functions
In JavaScript, scopes are declared by functions, and not by blocks. The scope of a declaration that’s created inside a block isn’t terminated (as it is in other languages) by the end of the block.
Consider the following code:
if (window) {
var x = 213;
}
alert(x);
In most other languages, one would expect the scope of the declaration for x to terminate at the end of the block created...