Data types

Data types and primitive values

JavaScript is a dynamically typed language. Types are defined at runtime, and automatic conversion is performed in certain situations (like when trying to add 4 to “5”). Also, you can easily switch types after having declared them.

Although some JavaScript engines might compile the code to make it faster, JavaScript is an interpreted language, and is served as plain text.

JavaScript is case-sensitive, so parseInt() is different than ParseInt().

Everything is an object

It’s funny how you hear that JavaScript isn’t object-oriented, when virtually everything in JavaScript is an object.

Strings are objects, numbers are objects, functions are objects. Arrays, regular expressions are objects, too.

Even global values and functions are actually properties and methods of the global object, which is a special object that is different in every implementation (ex., the browser, or Node.js), and gets created by the JavaScript engine before entering script execution to group things together (see http://msdn.microsoft.com/en-us/library/ie/52f50e9t(v=vs.94).aspx and http://www.ecma-international.org/ecma-262/5.1/#sec-15.1).

Data types

Data types in JavaScript are Boolean, null, undefined, Number, String, Symbol (new in ECMAScript 6) and Object.

See below for more info:

Source(s):

Leave a Reply

Your email address will not be published. Required fields are marked *