JavaScript Interview Questions(1)

皇甫浩壤
2023-12-01

1.What is JavaScript?

  • JavaScript is a scripting language.
  • It is different from Java language.
  • It is object-based, lightweight, cross-platform translated language.
  • It is widely used for client-side validation.
  • The JavaScript Translator (embedded in the browser) is responsible for translating the JavaScript code for the web browser.

2. List some features of JavaScript.

  • Lightweight
  • Interpreted programming language
  • Good for the applications which are network-centric
  • Complementary to Java
  • Complementary to HTML
  • Open source

3. List some of the advantages of JavaScript.

  • Server interaction is less
  • Feedback to the visitors is immediate
  • Interactivity is high
  • Interfaces are richer

4.List some of the disadvantages of JavaScript.

  • No support for multithreading
  • No support for multiprocessing
  • Reading and writing of files is not allowed
  • No support for networking applications.

5.Define a named function in JavaScript.

The function which has named at the time of definition is called a named function.

function msg()  
{  
  document.writeln("Named Function");  
}  
msg();  

6.Name the types of functions

  • Named - These type of functions contains name at the time of definition.
function display()  
{  
  document.writeln("Named Function");  
}  
display();  
  • Anonymous - These type of functions doesn’t contain any name. They are declared dynamically at runtime.
var display=function()  
{  
  document.writeln("Anonymous Function");  
}  
display();  

7.Define anonymous function

  • It is a function that has no name.
  • These functions are declared dynamically at runtime using the function operator instead of the function declaration.
  • The function operator is more flexible than a function declaration.
  • It can be easily used in the place of an expression.

8.Can an anonymous function be assigned to a variable?

Yes, you can assign an anonymous function to a variable.

9. In JavaScript what is an argument object?

The variables of JavaScript represent the arguments that are passed to a function.

10.Define closure.

  • In JavaScript, we need closures when a variable which is defined outside the scope in reference is accessed from some inner scope.
var num = 10;  
function sum()   
{  
document.writeln(num+num);  
}   
sum(); 
 类似资料: