JavaScript Descriptive Part-1

Posted by: | Published: Wednesday, August 31, 2016 | Categories:

JavaScript Descriptive : 

1. What is JavaScript? Or what are the characteristics of JavaScript? 
a.Client side object based scripting language.
b.Interpreted language.
c.Product of Netscape.
d.Weakly typed or un-typed.
e.Semicolon (;) is optional

2. What is the function of return statement?
The return statement is used to specify the value that is returned from the function. So, functions that are going to return a value must use the return statement. The example below returns the product of two numbers (a and b):




3. What do you mean by local and global variable?
 If we declare a variable, using "var", within a function, the variable can only be accessed within that function. When we exit the function, the variable is destroyed. These variables are called local variables. We can have local variables with the same name in different functions, because each is recognized only by the function in which it is declared. If we declare a variable outside a function, all the functions on our page can access it. The lifetime of these variables starts when they are declared, and ends when the page is closed. These variables are called global variables.

4. What is the difference between while and do-while loop?
The while loop loops through a block of code while a specified condition is true.
while (variable<=endvalue) { code to be executed } The do...while loop is a variant of the while loop. This loop will execute the block of code ONCE, and then it will repeat the loop as long as the specified condition is true. do { code to be executed } while (variable<=endvalue);

5. What is the function of break and continue statement?
The break statement will break the loop and continue executing the code that follows after the loop (if any). The continue statement will break the current loop and continue with the next value.

6. What is JavaScript Event?
 By using JavaScript, we have the ability to create dynamic web pages. Events are actions that can be detected by JavaScript. Every element on a web page has certain events which can trigger a JavaScript. Examples of events:
•A mouse click
•A web page or an image loading
•Mousing over a hot spot on the web page
•Selecting an input field in an HTML form
•Submitting an HTML form
•A keystroke

7. What do you mean by Array? How will you declare an array?
An array is a special variable, which can hold more than one value, at a time. There are three ways of defining an array:
a.var myfriends=new Array()  //1) regular array. Pass an optional integer argument to control array's size.
myfriends[0]="John"
myfriends[1]="Bob"
myfriends[2]="Sue"
b.var myfriends=new Array("John", "Bob", "Sue")  //2) condensed array
c.var myfriends=["John", "Bob", "Sue"]  //3) literal array

8. What is the difference between “==” and “===” operator?
Equal operator (==) check the condition whether two numbers or string values are equal Strictly equal operator (===) used to compare and check whether both values and their types are equal

9. What do you mean by “with” statements? Write it’s syntax.
JavaScript’s with statement was intended to provide a shorthand for writing recurring accesses to objects. So instead of writing var a=document.formname.elementname1.value;
var b=document.formname.elementname2.value;
We can write
with(document.formname){
var a= elementname1.value;
var b= elementname2.value;
}

10. What do you mean by DOM? Write its properties.
The Document Object Model (DOM) is the model that describes how all elements in an HTML page, like input fields, images, paragraphs etc., are related to the topmost structure: the document itself. In the JavaScript DOM the primary document is an HTML page. The document object contains the properties whose information is used by JavaScript. By calling the element by its proper DOM name, we can influence it.
Below lists the DOM properties that can be used on most elements in a document: attributes[],childNodes[],className, clientWidth, clientHeight, dir, firstChild, id, innerHTML, lang, lastChild, localName, namespaceURI, nextSibling, nodeName, nodeType, nodeValue, offsetLeft, offsetTop, offsetParent, offsetWidth, offsetHeight, ownerDocument, parentNode, prefix, previousSibling, scrollLeft, scrollTop, scrollHeight, scrollWidth, style, tabIndex, tagName, title.
Ref: http://www.javascriptkit.com/domref/elementproperties.shtml


Previous
Next Post »

আপনার কোন কিছু জানার থাকলে কমেন্টস বক্স এ লিখতে পারেন। আমরা যথাযত চেস্টা করব আপনার সঠিক উত্তর দিতে। ভালো লাগলে ধন্যবাদ দিতে ভুলবেন না।
- শুভকামনায় ওয়েব স্কুল বিডি
ConversionConversion EmoticonEmoticon