Tag Archives: tips

Why join a startup?

This started as a comment to a job posting that I posted in Facebook. This is simply a gist of differences between startup and corporate culture, that made me choose a startup (from a choice of 1 startup and 1 corporate) and that I realized in my 9 months experience at the startup. This post is mainly targeted at college students who have heard from their senior friends and relatives only about corporate world and not having much idea about how different startup culture is. That said, this may seem trivial to some people.

Here goes the significant differences, not in any particular order. I wouldn’t categorize them as pluses and minuses. Those who find more pluses than minuses (not just in count, but in overall effect) are potential candidates for a startup 😉

  • No one gives you work to do. You take up responsibilities.
  • There will be no one to teach/train you. You learn by mistakes and so your learning will be much stronger.
  • You get to learn a lot of new technologies. And those are open technologies that will be useful to you even if you leave the company.
  • You are free to experiment things, as the company itself is experimenting its business ideas.
  • From no other place you can learn business better, if you are interested.
  • The office may not be multi-storeyed and fancy, but there is nothing like the fun you can have (not just the fun of coding, contact me offline to know more :P).
  • There will be no fixed working hours. Not even the “If you finish the work you can leave” stuff. You work for your satisfaction. If you prefer usual 9AM-5Pm working hours, corporate world suits you better.
  • You can take up responsibilities of any higher level (that would otherwise take years in a corporate to reach that position), if you are really interested. (For example, I’ve interviewed people).
  • As the team is much smaller (mostly single digit), your efforts can never go unnoticed.
  • Your thoughts and ideas are so significant. And decision making will be truly democratic.
  • You may not get periodical salary hikes and goodies in initial years. But once established, the growth can be exponential.

In short a start-up is for those who want to achieve great heights by following their passion, definitely not for those who want a stable regular life.

If you feel I’ve missed some points, feel free to comment below. It will be helpful to at least me 🙂

Make your Javascript work perfect anywhere

For the past few weeks, I had a chance to work closely with Javascript and to understand it better;). I hope this post on my discoveries will help someone. Note this post is only about the cross-browser issues in javascript those I came across; I hope to write another post on general javascript tips.

One very basic thing you should always keep in mind while javascripting is that,

The environment on which your code will run is not in your hands.

Yes, the javascript engine which is going to compile your code may be a Spider Monkey, a TraceMonkey, a JägerMonkey, a Carakan, a SquirrelFish, a V8, a Chakra or even the sucking WSH. So you have to make sure that your code runs smart with any browser. Understanding how each of these engines work takes quite a lot of time. When you want to develop a cross-platform highly interactive web app in a short time, the following things are good to keep in mind.

Event handling

  • To know in which element the event occurred, use event.target and fallback to event.srcElement
    elem = event.target || event.srcElement;

Keyboard events

  • To know which key was pressed, use event.keyCode and fall back to event.which
    key = event.keyCode || event.which;
  • Use onkeydown if you want the event handler to be called continuously while the key is pressed and held. Suitable for backspaces, arrow key navigation, etc. Otherwise use onkeyup.
  • Never rely on punctuation keys. (These keys are dependant not only on browser and operating system, but also on keyboard configuration and the official system language).
  • To detect Alt, Shift and Ctrl keys, check if event.altKey, event.shiftKey and event.ctrlKey respectively are true. The keyCodes for these are less reliable on Mac.

Note: keypress event always returns 0 in Firefox.

Reference: http://www.quirksmode.org/js/keys.html

Callbacks and this

  • Value of this pointer is lost in callback functions. So,
    function outerFunction() {
      function print() {
        console.log('viky');
      }
      setInterval(this.print, 1000);
    }
    

    won’t work. Because inside setInterval, the value of this is lost. You can overcome this by copying this to something else, say that.

    function outerFunction(that) {
      var that = this;
      function print() {
        console.log('viky'); 
      }
      setInterval(that.print, 1000);
    }
    

    This can make your code messy. I would suggest you use Underscore.js bind and bindAll methods to bind this to functions.

Miscellaneous

  • Accessing characters in a string using normal way of indexing arrays, as in
    str[i]

    works fine in all browsers except IE. So, always use

    str.charAt(i)
  • split function using regular expressions as below doesn’t work in IE.
    var str = 'somestring';
    str.split(/[sr]/);
  • Comma at the end of an array or any object as in
    var position = { x: 5, y: 10, };

    works fine in all browsers but throws error in IE.