Posts

Showing posts from March, 2015

Java Expert RE-Learning Javascript Part 2 - Operators

What do you thing, what does javascript do with the following ? "5" + 1 - result? "51" 5 + "1" - result? "51" "5" - 1 - result? 4 "5" == 5 - result? true null == undefined - result? true How did you do? I was bad at it, especially to realize that "5" + 1 and 5 + "1" would make the same result. Javascript tries always to do conversion whenever the types of operands dont match. Javascript is pretty easy-going language. It allows you to do many things, giving you a bit of additional freedom. BUT you have to be VERY careful, as you can imagine that in some cases, above mentioned freedom might cost you a lot of bugs :) So, summary of rules in Javascript about operators: If you give Javascript different types to operate with, it will start doing type conversion. The way it would do it is based on set of (often confusing) rules. It would check first the operator, and then try to convert opera

Java Expert RE-Learning Javascript Part 1 - Intro

You know the time when you come across so many different programming languages, it happens that you come cross programming language you never really learn from scratch, but just "learn by doing". It has been like that all the way until I had "awakening" call, a job interview, where I got javascript questions which I did not know at all. The biggest issue was its similarity to Java/C programming languages, where many things I rather "assumed" it is the same, without ever really checking it out. After sobering up, I decided to RE-learn Javascript, and started reading book "Eloquent Javascript"  . after reading now already a quarter of a book, I am positively surprised how nice it was written. I strongly suggest to anyone, either a core beginner in programming (no pre-knowledge whatsoever is required to read it), or even a veteran programmer. This book has also very challenging exercises in the end which solutions (can be found on above link)