Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Recently I have become interested in learning Javascript for web development. I currently know HTML, CSS, and beginner/intermediate C++. I understand polymorphism, inheritance, and all of that fun stuff. Would any of these skills carry over to Javascript? In what key ways does Javascript differ from C++?

share|improve this question

closed as off-topic by gnat, MichaelT, Ixrec, GlenH7, Snowman Jan 29 at 20:53

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking career or education advice are off topic on Programmers. They are only meaningful to the asker and do not generate lasting value for the broader programming community. Furthermore, in most cases, any answer is going to be a subjective opinion that may not take into account all the nuances of a (your) particular circumstance." – gnat, Community, Ixrec, GlenH7, Snowman
If this question can be reworded to fit the rules in the help center, please edit the question.

Hello and welcome! You can get a basic overview of Javascript from its Wikipedia article, and you'll need to do some research into prototype based programming to start understanding the language. I've removed the recommendations part from your question because it's really off topic for Programmers. – Yannis Jun 7 '12 at 8:53
scope of this (gets defined 3 ways), anonymous functions, proto & function prototypes, html objects/web api, .... – Muhammad Umer Dec 23 '13 at 18:14
up vote 6 down vote accepted

The main difference which makes JavaScript really different compared to other languages with C like syntax is the function scope, compared to block scope. This leads to a dynamic this reference. Inheritance is also different and the dynamic, non-static type system might lead to confusion, but that's basically how you add new functionality. Of course, this has also some implications on projekct structure and so on.

I recommend JavaScript the good parts (O'Reilly), JavaScript patterns (O'Reilly) and Secrets of the JavaScript ninja (Manning).

But other than that, JavaScript can really be fun and once you get the idea, you might want to take a peek into CoffeeScript.

share|improve this answer
Alright, I will definitely check out those books. When I was messing around with Javascript the absence of a main loop definitely threw me off. – Zach Latta Jun 7 '12 at 8:47
Function scope has not much to do with dynamic this. The reason this is dynamic is that objects are just hash maps whose members may happen to be functions. As such, there is a need for this functions to get a reference to the containing object you are using in a given moment. – Andrea Jun 7 '12 at 8:51
You should definitely fall into the trap just hacking everything into a script tag. When getting a hang of JS, you should try to work with modules and separate Code from Markup (you can start easily with JQuery). But keeping at least everything in functions is required. So, the main can be simply a function bootstrapping your application. – Florian Salihovic Jun 7 '12 at 8:54
The biggest difference is probably first-class functions. – Florian Margaine Jun 7 '12 at 10:51
I would add prototype based inheritance versus class based. – Cronco Jun 7 '12 at 11:07

I'm in a similar situation, I'm coming to javascript from the C# world. I'm still a noob with javascript, but I can share some of my personal experience with you.

First of all here is a link from someone with more knowledge than me, that targets your question specifically: "JavaScript Jump Start For C++ Programmers"

Your knowledge will help you understand Javascript faster, but be careful, they are very different languages, and some of the things you have gotten used to might become caveats.

Here are some things that have brought me pain so far:

Javascript is dynamically typed, not statically typed. Because of this, typos in property names have become a problem for me... And sometimes you have to use the debugger to see if you are using the right properties from parameters.

It's Interpreted, not compiled. That means that you will find many of the errors only at runtime. And it might happen that your code to executes only partially when you have an error.

Be very careful when you use the 'this' keyword, it's not behaving like you are used to. Here's an article describing this in detail:

There is also a lot of strangeness regarding 'falsy' and 'truthy' values (see this:

This is a big topic, and I'm sure the answer is not complete, so I invite others to edit it.

share|improve this answer
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Yannis Jun 7 '12 at 8:53
I get your point, and I agree with it, but I don't see the reason for the downvote... I will add more details to the answer .. when I have more time. – stralsi Jun 7 '12 at 9:09
@SilviuStraliciuc after adding details you mention, please feel free to ping me so that I can re-consider my current downvote of your answer – gnat Jun 7 '12 at 9:36
@SilviuStraliciuc The tooltip to the down vote reads "this answer is not useful", and it's not, at least to me. – Yannis Jun 7 '12 at 9:59
first link seems to be down :( – darklon Jan 27 at 15:43

Do you know Design Patterns?

The reason being that this really helps in the transition. It may be beneficial to realize that the following patterns have specific importance in JavaScript:

Namespace (Module) Pub-Sub (Observer).

It is important to understand the Module Pattern in JavaScript, and how it relates to global scope specifically. I would impart that private member variables and classical object-oriented design are different.

JS is flexible because it doesn't have a class.In JS... it is all just objects, at runtime - operating on the DOM(important). JavsScript objects are essentially one in the same to the notion of JSON, 'discovered' by Douglas Crockford. He is one expert.

JSON is a JavaScript Object transfer format that is used in AJAX applications. It is possible to pass these objects... all over, regarding node.js

Inheritance is different in JavaScript. One very fine presenter defined it as: "JavaScript is friendly to you - It wont yell at you during errors." and "Inheritance is like a backpack, you just put stuff in it"-venkat submariam at RWX.

MVC is also super important in my humble opinion. I like backbone.js there are others.

It is a great language highly recommend it! It has been great since my transition from c++; and sure do miss arduino.


share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.