Wednesday, April 20, 2011

Day 1 Last session : Javascript powerful language out there

Last session of the day by Venkat on the power of Javascript

Javascript

Feels like Java & C
Similar to perl in some ways
Untyped Language

Rules

1) Case sensitive
2) goo idea to use ;
3) commenting style is same as Java/C++
4) null and undefined are used to indicated null
5) Strings are single or doule quotes and are immutable

Functional in nature : Functions are first class citizens

Pass and return functions. Everything should be object oriented is a wrong notion.

Variables are typeless. but you need to declare variables with var

Global and local scoping for variables. No block level.

Control structures are like C : statements, expressions, for loops

var sayHello = function(name) {
print('hi');
}

sayHello is now a handle to a function.Its powerful since, you can now register them as event handlers.

IN Javascript everything is an expression. there is no statement as such.

Functions are Objects


function Car(year) {
this.year=year;
}

var myCar = new Car(2011);

print (myCar.year);

myCar is an instance of Car.

Encapsulation is not really about security. Its for code maintainence.

prototype is like a backpack. Any method not defined on object is routed to prototype.

Car.prototype.drive = function(dist) {
print('driving..);
this.miles += dist;
}
Car.prototype.tune = function() {print ('tune')};

print (myCar["year"]); --> you can use this instead of dot notation. You can dynamically recieve the parameter since its in a double quote.

Object is nothing but a collection (property holder).
It can be a function, object or a collection of properties

for (var prop in myCar.__proto__) {
print(prop + '\n');
}


Inheritance in Javascript

Composition is better than Inheritance. Ruby and Groovy have delegation (@delegate).

Javascript supports inheritance through method composition.

function Base() {
}

function Dervied() {
}

Derived.prototype = new Base();

Code Quality

jslint is a nice tool to check code quality.

You need to separate the logic from HTML page.

Overall it was an amazing session with good insights on JS

13 comments:

Anonymous said...

I'm extremely pleased to uncover this great site. I wanted to thank you for ones time for this particularly fantastic read!! I definitely appreciated every part of it and I have you book marked to see new stuff on your site.

My blog - silk'n

Anonymous said...

Eveгy weekend і useԁ to рay a quick ѵiѕit thіs website, aѕ
i want enjoуment, since this this web pagе conations
truly pleаsant funny information tоo.

Lοοk at my blog; v2 cigs reviews

Anonymous said...

Whаt's up everyone, it's my first pay а quick visit аt this wеbѕіte, and pаragraph
is genuіnеly fruitful foг me, keеp up posting theѕe tyрeѕ of
artіcles.

Fееl fгee tо visit my ѕite V2 Cig Review
my website > v2 cigs reviews

Anonymous said...

Somebody essentially lеnd a hanԁ
to makе ѕignificantly pοsts I
mіght state. This is the firѕt tіmе I fгequented уour
web ρage and thus far? I surprіsed with the analysis
yοu made to makе thiѕ actuаl put uр
amazing. Magnificent taѕk!

Also vіѕit my blοg :: Read the Full Report

Anonymous said...

Еxcellent blog herе! Also youг website loaԁѕ up fast!
What host aгe you using? Can I get your affiliаte link to yοuг host?
I wish my web site lοаded up as quіcκly as yоurs
lol

Herе iѕ my weblog just click the up coming web site

Anonymous said...

Ιt's an remarkable paragraph in favor of all the internet viewers; they will take benefit from it I am sure.

Also visit my homepage; V2 Cigs review

Anonymous said...

I waѕ eхtremеlу pleаsеԁ to diѕcоver this webѕite.
I wanted to thаnk уou foг youг time just for thіs ωοndeгful read!
! I definіtelу appгeciateԁ еverу рагt of it and i alѕo
haѵe you sаνed tο fav tо
look аt nеw information in yоur blog.


Viѕit my web-site: http://www.prweb.com/releases/silkn/sensepilreview/prweb10193901.htm

Anonymous said...

This is a topіc thаt's near to my heart... Best wishes! Exactly where are your contact details though?

Also visit my homepage - click the up coming site

Anonymous said...

I got this wеbsіte from my ρal who shared
wіth me on the topiс of thіs web page anԁ now this time I
аm viѕiting this ѕitе anԁ reading very
informative content аt this placе.


my homepagе: http://bernd-schmitz.net/wiki/index.php?title=V2_Cigs_Are_Best_For_My_Asthma_Suffering_Parents

Anonymous said...

Prettу nіce post. I just stumbled upon уour
weblog and wanted to say that I've really enjoyed browsing your blog posts. After all I will be subscribing to your feed and I hope you write again soon!

Feel free to surf to my blog :: click the next document

Anonymous said...

I tell fоlkѕ every day conсerning your product.
I woгk in the wellneѕs industrу ωhen my Ρt's inform me they are attempting to stop smoking, We tell them regarding Green Smoke. I tell them don't
buy аn inexpensіνe brand, purchase a top οf thе lіnе meгchаndise еsреcially if you are usually
sеriouѕ about quiting.

my webpage; green smoke e cig reviews

Anonymous said...

We offer a number of nicotine choіces ranging from Robust to Mild.
We even offer a zero-niсotine alternаtіve.


Fеel free tо suгf tο
my web blog; Green gorilla smoke shop

Anonymous said...

Ahaa, іts niсe discussion on the topic of this piece
of writing here at this web site, I have rеad all that, ѕo at this time me also сommenting at this place.



Hеre iѕ my weblog Recommended Web site