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++?

  • 4
    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, 2012 at 8:53
  • scope of this (gets defined 3 ways), anonymous functions, proto & function prototypes, html objects/web api, .... Dec 23, 2013 at 18:14

3 Answers 3


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.

  • 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, 2012 at 8:47
  • 1
    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, 2012 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. Jun 7, 2012 at 8:54
  • 1
    The biggest difference is probably first-class functions. Jun 7, 2012 at 10:51
  • 2
    I would add prototype based inheritance versus class based.
    – Cronco
    Jun 7, 2012 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" https://web.archive.org/web/20140206141018/http://localjs.org/docs/en/tutorial_js4cpp.php

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: http://javascriptweblog.wordpress.com/2010/08/30/understanding-javascripts-this/

There is also a lot of strangeness regarding 'falsy' and 'truthy' values (see this: http://11heavens.com/falsy-and-truthy-in-javascript).

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

  • 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, 2012 at 8:53
  • 3
    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, 2012 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, 2012 at 9:36
  • 1
    @SilviuStraliciuc The tooltip to the down vote reads "this answer is not useful", and it's not, at least to me.
    – yannis
    Jun 7, 2012 at 9:59
  • 1
    first link seems to be down :(
    – darklon
    Jan 27, 2016 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.


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