Monthly Archives: March 2013

JavaScript Data Types

1. What is a String Data Type in JavaScript?
String is a type of variable that is capable of storing data, which is series of characters. It can be used in quotes, or even double quotes.

2. Give 3 examples of data considered as String.
Series of characters such as “John Doe”, Inside quotes, or double quotes.

3. What is an Integer Data Type?
Integer is another type of variable in JavaScript, that is capable of storing numbers. Integer values can be positive whole numbers, negative whole numbers, and 0. They can be represented in base 10 (decimal), base 16 (hexadecimal), and base 8 (octal). Most numbers in JavaScript are written in decimal.

4. Give 3 examples of data considered as Integer.
It is decimal, hexadecimal, and octal.

5. What is a Floating-point value?
Floating-point value can be described in scientific notation, it can also be a whole number with a decimal portion. In scientific notation, an uppercase or lowercase “e” is used to represent “ten to the power of”. JavaScript shows numbers using the eight byte program: IEEE 754 floating-point standard for numerical representation. This means you can write numbers as large as 1.79769×10^(308)^, and as small as 5×10^(-324)^. A number that contains a decimal point and that has a single “0” before the decimal point is interpreted as a decimal floating-point number.

6. Give 3 examples of data considered as Floating-point numbers.
It could be whole number with a decimal portion, a scientific notation, or even a mix between those two such as: 3.45e2 meaning 3.45 multiplied by ten to the power of 2, ending up with a 345.

7. What are the two values considered as Boolean Data Type?
They are the literals true and false.

8. What are the Composite Data Types?
It is object and array.

9. What are the Special Data types in JavaScript?
It is null and undefined.

Web Sources:


Intro to JavaScript

1. What is JavaScript?
JavaScript is a Scripting language, a scripting language is a lightweight programming language. JavaScript is a programming code that can be inserted into HTML pages.JavaScript inserted into HTML pages, can be ignored by all modern web browsers.

2. What company started JavaScript?
Netscape Communications Corporation, and Mozilla Foundation.

3. Explain briefly the main difference of Java and JavaScript.
First of all, the JavaScript programming language, developed by Netscape, Inc., is not part of the Java platform.Here are some of the key differences: Java is an OOP programming language while Java Script is an OOP scripting language. Java creates applications that run in a virtual machine or browser while JavaScript code is run on a browser only. Java code needs to be compiled while JavaScript code are all in text. They require different plug-ins.

4. What are the things can we do to a webpage using JavaScript?
It can be set to execute when something happens on the website, like when a page has finished loading or when a user clicks on a button.

5. Where do we write JavaScript codes? On which programs/applications?
You can put it on a HTML, you can place your code in either the head section, or the body section of your HTML page. Programs such as Notepad ++, Adobe Dreamweaver will work.

6. How can we see the result of our JavaScript code?
By opening a browser.

7. What is the HTML tag to start a JavaScript code?
It is: script type=”text/javascript” This is the HTML tag to start a Javascript code.

8. What is a variable? How is it different to a value?
Variable is a storage location and an associated symbolic name (an identifier) which contains some known or unknown quantity or information, which is the value. THe difference is that variable is the storage. and value is the quantity of information that the variable contains.

9. What are the data types in JavaScript?
It is String, Number, Boolean, Array, Object, Null, and Undefined.

10. How do we write comments in JavaScript?
Comments will not be executed by JavaScript.Comments can be added to explain the JavaScript, or to make the code more readable. Single line comments start with //. Below is an example:
// Write to a heading:
document.getElementById(“myH1″).innerHTML=”Welcome to my Homepage”;
// Write to a paragraph:
document.getElementById(“myP”).innerHTML=”This is my first paragraph.”;

Web Sources Link: