Free Web Development Online Tutorials, Learn to Code
JavaScript basic interview questions for freshers, Advanced JavaScript interview questions

JavaScript basic interview questions for freshers

javascript Interview Questions Answers

Advanced Javascript Interview Questions

What is JavaScript?
JavaScript is a client-side Programming language, but also can be used as server side scripting language, JavaScript can be used with all web development technologies like java, asp.net, php, python etc. JavaScript can post data to serve side and external API. JavaScript is an open source and cross-platform scripting language.
Which company developed JavaScript?
Netscape, a software company who developed JavaScript.
What are the different Data Types in JavaScript?
  • String
  • Number
  • Boolean
  • Undefined
  • Null
  • Object
What is 'this' keyword in JavaScript?
'this' keyword refers the current object from where it was being called.
What is the use of isNaN function?
isNan function returns boolean value true if the argument is not a number otherwise it is false.
How to comment any code in Javascript?
Single line comment example
// for Single line comment
Multi line comment example
/* Multi 
line 
comments */
What are the different types of loops in JavaScript?
  • For loop
  • While loop
  • do-while loop
Learn more about loop in javascript with examples
Can we access JavaScript function written in a different file? If yes then how?
Yes, we can add access JavaScript function written in a different file by adding the file reference.
<script src="~/Scripts/jquery.validate.js"></script>
Is JavaScript a case-sensitive language?
Yes, JavaScript is a case sensitive scripting language. So when we define any variable (like var k;), while accessing we have to use the same case, otherwise it will be considered as a different variable
    var k;
    var K; // different ;
What is the difference between "not defined" and "undefined" in JavaScript?
When we try to use any variable that has not been declared or doesn't exist then JavaScript will throw an error var name is not defined.
var a; // declaring x
console.log(a); //output: undefined 

Now if we try to user some variable that has not been declared before

var a; // Declaration
console.log(b);  // Output: ReferenceError: b is not defined
How to create an object in JavaScript?
There are many different ways we can create object in JavaScript, here is a common example
var Employee = function (name, org, salary) {
    this.name = name || "";  //attribute default value is null
    this.organization = org || ""; 
    this.salary = salary || 5000; 
}
var emp1 = new Employee("Bill","Microsoft",3000);
var emp2 = new Employee("Whitney","IBM",5000);
How to declare an array with some default values in JavaScript?
Usually we always declare any array with some values assigned in it, here is how we can do
    var colors =  ['red','blue','orange','while','black','green'];
Learn more about JavaScript Array with example
How to define anonymous function in JavaScript
This type of function has no name, anonymous can be easily declared in like an expression, starts with function keyword.
<script> 
var helloWorld = function () {
    alert("Anonymous function invoked");
}
helloWorld();
</script> 
Learn more about JavaScript Function with example
Comment
Name
Email
Website
Subscribe