Data Types

As I mentioned earlier, JavaScript is a language that is dynamically typed. By this I mean that the language infers a lot of what you can do with certain data by the type of data you use. If you passed 2 + 2 to a JavaScript engine, most likely you want to perform a mathematical operation and get the result of the operation (4) and not print out “2 + 2.” However, if you had “JavaScript” + “Rocks,” adding these together to get a numeric value doesn't make much sense.

In programming languages, these are called data types, and in JavaScript, the JavaScript engine dynamically interprets this information. That's not to say that you don't need to know about data types and sometimes assign them yourself. Why is this important? Didn't I say ...

Get Beginning Facebook Game Apps Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.