JS Data Types and JS Comments

0 123

Javascript Data Types and Javascript Comments

in this tutorial i will briefly discuss Javascript Data Types and Javascript Comments

Data Types in JavaScript

Different type’s value can be store in JavaScript such as number character or string values. JavaScript provides different type data types to store different type values.
In JavaScript, a web developer does not need to specify data type while declaring variables due to this JavaScript referred to loosely typed language. This means that a variable holding a number can also hold a string value later.

Data types in JavaScript are classified into two broad categories namely, primitive and composite data types. Primitive data types contain only a single values whereas composite contains groups of value.

Primitive Data Types

Primitive Data Types contains only single literal values such as number and string.

Primitive Data Types are…

Primitive Data Type Description
null null data type contain only one value null .variable of such kind variable has no value and it is not the same as the value zero
number number Primitive Data Type Contains positive and negative numbers and numbers with the decimal point.
string Contains alphanumeric characters in single or double quotation marks. The single quotes are used to represent a string. Double quotes without any value called null string.

Composite Data Types

In JavaScript Composite Data Types use to store the collection of multiple related values. All Composite Data Types are treated as objects. Composite Data Types can be predefined or user defined in JavaScript.

Composite data types are.

Composite Data Type Description
Objects objects in JavaScript Refers to a collection of properties and functions.
Functions Function are Refers to a collection of statements which are instructions to achieve a specific task.
Arrays To store a collection of value in memory locations array data type used

Comments in JavaScript

For example, a web developer creating a very complex website like online shopping he would have to write bunches of codes.it will be really tedious to debug later any error. To make it easy like an every programming languages javascript also allows a user to comments any codes easy to understand and debug if any error occurs. Comments describe the code in simple words so that somebody who reads the code can understand the code.
In other words, we can say Comments are the special character which browser can’t read and show in browser, comments are only for the developer to help debug or to reuse his/her codes. You can use comments for a single line or to multiple lines.

Single-line Comments

Single-line Comments begins with two forward slashes //

Multi-line Comments

Multi-line comments begin with the forward slash followed by an asterisk /* and end with an asterisk followed by a forward slash */.

Comments to Prevent Execution

To prevent execution of code comments can be used for code testing.



Leave A Reply

Your email address will not be published.