Do you know Javascript … Try these puzzle

Do you know Javascript … Try these puzzle

Javascript is one the most miss-understood language among developers. Everyday I learn new lesson about it.While going through few articles I thought of following JS language puzzles.

Handling Array
var days = ['Monday', 'Tuesday','Wednesday','Thursday','Friday', 'Saturday'];
var  length = days.length;
console.log('No of days are ' + days.length);
//Opps we missed Sunday, lets add it
days[++length] = 'Sunday';

console.log('Final no of days are ' + days.length);

It is obvious that no of days are 7…. is it ?

Written with StackEdit.


  1. StackEdit is a full-featured, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites.
  2. Here is the text of the footnote.

Comments

  1. 8 because you are adding the element at the 7th index?

    ~alosh

    ReplyDelete

Post a Comment

Popular posts from this blog

Composite Design Pattern by example

State Design Pattern by Example

Eclipse command framework core expression: Property tester