Top 100+ Oojs Interview Questions And Answers
Question 1. Is Javascript Case Sensitive?
Answer :
Yes! JavaScript is a case touchy because a feature str isn't equal to Str.
Question 2. What Is The Type Of Javascript?
Answer :
There are one of a kind of Type as given below.
String,
Number,
Boolean,
Function,
Object,
Null,
Undefined and so on
Java Script Interview Questions
Question 3. What Types Of Boolean Operators In Javascript?
Answer :
There are three kinds of Boolean operators as given under) operator and
NOT (!) Operator
Question four. What Is The Difference Between “==” And “===”?
Answer :
The double same “==” is an auto-type conversion and it checks most effective value not kind.
The 3 equal “===” isn't always automobile-type conversion and it test fee and type both.
The real instance as given underneath:
if(1 == ”1”) // Its returns proper as it's an vehicle-type conversion and it assessments most effective cost no longer type.
If(1 === ”1”) // Its returns false as it's now not auto-kind conversion and it check fee and type both.
If(1=== parseInt(”1”)) // Its returns genuine.
// alert(0 == false); // go back genuine, because both are equal type.
// alert(zero === fake); // go back false, because each are of a exceptional type.
// alert(1 == "1"); // return authentic, automatic type conversion for price most effective.
// alert(1 === "1"); // return fake, because both are of a exceptional kind.
// alert(null == undefined); // go back authentic.
// alert(null === undefined); // return false.
//alert('0' == fake); // go back proper.
// alert('0' === fake); // go back false.
// alert(1=== parseInt("1")); // go back authentic.
Java Script Tutorial
Question 5. What Is An Object?
Answer :
The item is a set of homes and the each assets associated with the call-fee pairs. The object can comprise any data sorts (numbers, arrays, item and so forth.)
The instance as given under
Var myObject= empId : “001”, empCode :”X0091”;
In the above instance, here are homes one is empId and different is empCode and its values are “001” and “X0091”.
The homes name can me string or quantity. If a belongings call is number i.E.
Var numObject= 1 : “001”, 2 :”X0091”;
Console.Log(numObject.1); //This line throw an errors.
Console.Log(numObject[“1”]); // will get entry to to this line not get any mistakes.
As consistent with my thought, the variety property name need to be prevented.
Angular JS Interview Questions
Question 6. What Is Scope Variable In Javascript?
Answer :
The scope is about of items, variables and feature and the JavaScript will have international scope variable and nearby scope variable.
The worldwide scope is a window object and its used out of function and within the functions.
The local scope is a characteristic object and its used within the functions.
The example for global scope variable
var gblVar = "Anil Singh";
feature getDetail()
console.Log(gblVar);
and different example for global
feature demoTest()
x = 15;
;
console.Log(x); //out placed is 15
The example for neighborhood scope variable
characteristic getDetail()
var gblVar = "Anil Singh";
console.Log(gblVar);
and different instance for neighborhood
feature demoText()
var x = 15;
;
console.Log(x); //undefined
Question 7. What Is Array?What Is Associative Arrays In Javascript?
Answer :
Array is a group of index objects and it's miles various indexes.
Some of programming language aid array as named indexes and the JavaScript no longer support the array as call indexes and its offer simplest number indexes but offer this option the use of the associative array.
The array with name indexes are called associative array and the associative array is offer a long way to save the statistics.
The variety index array example as given underneath
var customers = new Object();
users["Name1"] = "Anil 1";
users["Name2"] = "Anil 2";
users["Age"] = 33;
alert(Object.Keys(users).Duration); //output is three.
Var period = Object.Keys(customers).Period; // 3
The call index array example as given beneath
var customers = [];
customers["Name1"] = "Anil 1";
customers["Name2"] = "Anil 2";
users["Age"] = 33;
var duration = customers.Period; // customers.Length will return 0
var detail = customers[0]; // customers[0] will return undefined
JavaServer Faces (JSF) Tutorial JavaServer Faces (JSF) Interview Questions
Question eight. Where To Use The Associate Array?
Answer :
I am going to give an explanation for the partner array over the database desk columns. A desk have a few columns and its type. I.E.
The empName as text kind, empAge as quantity kind and enpDOB as date type.
If we need to discover the type of a column that point we can create the companion array. I.E.
Var empDetailType = new Array();
empDetailType["empName"] = "ANil";
empDetailType["empAge"] = 30;
empDetailType["empDOB"] = "10/03/1984";
console.Log("Find the emp age type :" + empDetailType["empAge"]);
Question nine. How To Achieve Inheritance In Javascript?
Answer :
In the JavaScript, we are able to implement the inheritance using the some alternative ways and we can't outline a class key-word but we create a constructor function and the use of new keyword obtain it.
The a few opportunity ways as given below.
Pseudo classical inheritance
Prototype inheritance
Pseudo classical inheritance is the maximum famous way. In this way, create a constructor characteristic the usage of the new operator and upload the contributors characteristic with the help for constructor characteristic prototype.
The prototype based totally programming is a technique of object orientated programming. In this mechanism we can reuse the exiting gadgets as prototypes. The prototype inheritance also realize as prototypal,
classless or instance based totally inheritances.
The Inheritance example for prototype based totally as given under
// Create a helper feature.
If (typeof Object.Create !== 'function')
Object.Create = characteristic (obj)
function fun() ;
fun.Prototype = obj;
return new a laugh();
;
//This is a discern magnificence.
Var figure =
sayHi: feature ()
alert('Hi, I am figure!');
,
sayHiToWalk: function ()
alert('Hi, I am figure! And going to stroll!');
;
//This is child elegance and the discern class is inherited inside the baby elegance.
Var infant = Object.Create(parent);
baby.SayHi = characteristic ()
alert('Hi, I am a child!');
;
<button type="submit" onclick="child.SayHi()"> click to oops</button>
The output is : Hi, I am a child!
Ext JS Interview Questions
Question 10. What Is Typeof Operator?
Answer :
The typeof operator is used to locate the form of variables.
The example as given under.
Typeof "Anil Singh" // Returns string
typeof three.33 // Returns number
typeof proper // Returns Boolean
typeof call: 'Anil', age: 30 // Returns item
typeof [10, 20, 30, 40] // Returns object
Ext JS Tutorial
Question 11. What Is Public, Private And Static Variables In Javascript?
Answer :
I am going to give an explanation for like strongly kind item oriented language (OOPs) like(C#,C++ and java and so on.).
Fist I am developing a conductor class and seeking to attain to declare the general public, private and static variables and detail as given underneath.
Function myEmpConsepts() // This myEmpConsepts is a constructor feature.
Var empId = "00201"; //This is a personal variable.
This.EmpName = "Anil Singh"; //This is a public variable.
This.GetEmpSalary = characteristic () //This is a public method
console.Log("The getEmpSalary technique is a public technique")
//This is a instace method and its name at the only one time when the decision is instanciate.
MyEmpConsepts.Prototype.EmpPublicDetail = function ()
console.Log("I am calling public vaiable within the istance method :" + this.EmpName);
//This is a static vaiable and its shared with the aid of all instace.
MyEmpConsepts.EmpStaticVaiable = "Department";
var instanciateToClass = new myEmpConsepts();
Node.Js Interview Questions
Question 12. Who To Create The Namespace In Javascript?
Answer :
Please see the under example for how to create the namespace in JavaScript.
//Create the namespace.
Var nameSpace = nameSpace ;
nameSpace.MyEmpConsepts = function ()
var empId = "00201"; //This is a non-public variable.
This.EmpName = "Anil Singh"; //This is a public variable.
//This is public characteristic
this.GetEmp = function ()
go back "Anil Singh"
//This is private function
var getEmp = characteristic ()
go back "Anil Singh"
return
getEmp: getEmp,// paintings as public
getEmp: getEmp // work as public
();
Java Script Interview Questions
Question 13. How To Add/eliminate Properties To Object In Run-time In Javascript?
Answer :
I am going to provide an explanation for via instance for add and dispose of residences from JavaScript items as provide underneath.
This example for delete belongings.
//This is the JSON object.
Var objectJSON =
identity: 1,
call: "Anil Singh",
dept: "IT"
;
//This is the technique to delete
delete objectJSON.Dept;
//Delete belongings by using the array series
MyArrayColection.Prototype.Eliminate = feature (index)
this.Splice(index, 3);
This instance for add belongings
//This is used to add the belongings.
ObjectJSON.Age = 30;
console.Log(objectJSON.Age); //The result is 30;
//This is the JSON object.
Var objectJSON =
id: 1,
call: "Anil Singh",
dept: "IT",
age :30
;
Node.Js Tutorial
Question 14. How To Extending Built-in Objects In Javascript?
Answer :
JavaScript aid built-in items which use to broaden the flexibility of JavaScript. The built in object are date, string, math, array and object. It's very similar to different languages and its available in the window content and wok independently while brewers are loaded.
Example as provide beneath
var date = new Date(); //This is date built-in object.
Var math = Math.Abs(10); // this is math integrated item.
Var string = "my string" // this is string built-in item.
Question 15. Why Never Use New Array In Javascript?
Answer :
We have some fundamental troubles with new Array() the instance in element for array constructor characteristic as given below.
When array have extra the only integer?
Var newArray = new Array(10, 20, 30, forty, 50);
console.Log(newArray[0]); //returns 10.
Console.Log(newArray.Duration); //returns five.
When array have handiest one integer?
Var newArray = new Array(10);
console.Log(newArray[0]); //returns undefined
console.Log(newArray.Duration); //returns 10 due to the fact its has an errors "array index out of sure";
//This is the essential deference to want to avoid the brand new array();
Koa.Js Interview Questions
Question sixteen. What Is Eval() And Floor() Functions In Javascript?
Answer :
The eval() characteristic utilized in execute an argument as expression or we can say that examine a string as expression and it used to parse the JSON.
The example over eval() characteristic as given beneath.
Var x = 14;
eval('x + 10'); //The output is 24.
Another over eval() feature instance
eval('var myEval = 10');
console.Log(myEval); // The output is 10.
The ground() characteristic is a static approach of Math and we will write as Math.Ground() and used to spherical the quantity of downwards. I.E.
Math.Floor(1.6);//The output is 1.
Koa.Js Tutorial
Question 17. What Is Join() And Isnan() Functions In Javascript?
Answer :
The is be a part of() characteristic used to enroll in the separator inside the array.
Syntax: myArray.Join(mySeparator);
The instance as given below.
Var alfabets = ["A", "B", "C", "D"];
//Join with out seperator
var result1 = alfabets.Be part of();//The output is A B C D.
//Join with seperator.
Var result2 = alfabets.Be part of(','); //The output is A, B, C, D.
The isNaN() characteristic is used to test the price is not-a-wide variety.
The instance as given below
var var1 = isNaN(-1.23);//The output is fake.
Var var2 = isNaN(3);//The output is false.
Var var3 = isNaN(0);//The output is false.
Var var3 = isNaN("10/03/1984"); //The output is actual.
EmberJS Interview Questions
Question 18. What Is Closure In Javascript?
Answer :
While you create the JavaScript feature within another function and the internal feature freely get admission to all the variable of outer feature. I.E.
Characteristic ourterFun(i)
var var1 = three;
feature innerFun(j)
console.Log(i + j + (++var1)); // It will go back the sixteen.
InnerFun(10);
ourterFun(2); // Pass an issue 2
The output will get sixteen because innerFun() feature can get admission to to the argument "i" & variable "var1" but both are outline in the outerFun() function this is closure.
That means absolutely getting access to variable outdoor of your scope create a closure.
// OR Other WAYS
feature ourterFun(i)
var var1 = three;
go back function (j)
console.Log(i + j + (++var1)); // It will go back the 16.
Var innerFun = ourterFun(2); // innerFun() characteristic is now a closure.
InnerFun(10);
Angular JS Interview Questions
Question 19. What Is Javascript Hoisted?
Answer :
In the JavaScript, the variables can be used before declared, this forms of mechanism is called Hoisted. It's a default behavior of JavaScript.
You can without difficulty expertise within the under instance in element.
//The variable declaration appear like.
Var emp;
//The variable initialization look like.
Emp = "Anil Singh";
var emp; //The announcement of emp is hoisted however the cost of emp is undefined.
Emp = 10; //The Assignment nevertheless happens in which we meant (The cost of emp is 10)
characteristic getEmp()
var emp; //The statement of a distinct variable name emp is hoisted but the value of emp is undefined.
Console.Log(emp); //The output is undefined
emp = 20; //The challenge values is 20.
Console.Log(emp); //The output is 20.
GetEmp();
console.Log(emp); //The variable named emp within the outer scope nevertheless includes 10.
EmberJS Tutorial
Question 20. What Is Function Overloading In Javascript?
Answer :
There is not any actual feature overloading in JavaScript and it lets in to bypass any range of parameters of any kind.
You have to check within the feature how many arguments were passed and what is the type arguments usingtypeof.
The instance for feature overloading not helping in JavaScript as deliver underneath.
Function sum(a, b)
alert(a + b);
feature sum(c)
alert(c);
sum(three);//The output is 3.
Sum(2, four);//The output is 2.
In the JavaScript, when we write a couple of capabilities with equal call that point JavaScript recollect the last outline feature and override the previous capabilities. You can see the above example output for the same.
We can acquire the usage of the several special strategies as supply under
You can check the declared argument name value is undefined.
We can take a look at the overall arguments with arguments.Period.
Checking the type of passing arguments.
Using quantity of arguments
Using optionally available arguments like x=x one-of-a-kind name in the first vicinity
We can use the arguments array to get entry to any given argument by means of the use of arguments[i]
Backbone.Js Interview Questions
Question 21. What Is Prototype In Javascript?
Answer :
The prototype is a fundamental concept of JavaScript and its should to regarded JavaScript builders.
All the JavaScript gadgets has an item and its belongings known as prototype and its used to feature and the custom functions and assets.
The example without prototype as given underneath.
Var worker = characteristic ()
//This is a constructor function.
//Create the example of above constructor function and assign in a variable
var empInstance = new employee();
empInstance.Deportment = "IT";
console.Log(empInstance.Deportment);//The output of above is IT. The instance with prototype as given underneath.
Var worker = characteristic () //This is a constructor feature.
Employee.Prototype.Deportment = "IT";//Now, for every instance employee will have a deportment.
//Create the example of above constructor function and assign in a variable
var empInstance = new employee();
empInstance.Deportment = "HR";
console.Log(empInstance.Deportment);//The output of above is IT not HR.
Question 22. What Are Different Data-kinds Of Javascript?
Answer :
Following are different facts-kind in JavaScript.
String
Number
Boolean
Function
Object
Null
Undefined
Backbone.Js Tutorial
Question 23. What Are Different Two Ways Of Creating An Object?
Answer :
Object Literals: This is the most common way to create the item with item literal.
For Example:
var emptyObj= ;
Object Constructor: It is way to create item the use of item constructor and the constructor is used to initialize new object.
For Example:
Var obj = new Object();
Global variable: A variable which may be variable from any where of the page.
Following are distinctive ways.
First Way Declare the JavaScript variable on the pinnacle of JavaScript code and out of characteristic & gadgets.
Var globalVariable1 ='This is international variable 1'
Second WayDeclare a varaible without "var" in Function.
Characteristic testfunction()
globalVariable2 ='This is international variable 2'
D3.Js Interview Questions
Question 24. Why "self" Is Needed Instead Of "this" In Javascript?
Answer :
In this put up, I am percentage the “Why self is needed rather than this in JavaScript?” and also what's the benefit of the use of “var self = this;”
var self = this;
In the JavaScript, “self” is a pattern to preserving a reference to the original “this” keyword and also we can say that that is a method to address the events.
Right now, “self” should now not be used due to the fact present day browsers provide a “self” as worldwide variable (window.Self).
Example [“self” keyword is needed instead of “this”],
var worker = function (call)
var self = this;
self.Username = call;
;
JavaServer Faces (JSF) Interview Questions
Question 25. The Terms “scope” And “context” Refer To The Same Thing In Javascript ?
Answer :
False, Scope pertains to the visibility of variables, and context refers back to the item to which a technique belongs (which can be modified via using name or practice).
JSON (JavaScript Object Notation) Tutorial
Question 26. If You Omit The “var” Keyword When Creating A Variable In A Function, It Becomes A Property Of What Object?
Answer :
When omitting the “var” keyword, the variable you create will become an “implied worldwide”. But implied globals aren't variables in a feature. An implied global definitely will become a property of the window object. Although the window object is taken into consideration the “international” scope, it's miles an item, and any variable declared in the international scope (intentionally or otherwise), will become a belongings of the window item.
JSON (JavaScript Object Notation) Interview Questions
Question 27. How Do You Determine If A Javascript Instance Object Was Created From A Specific Constructor Or Not?
Answer :
Use the instanceof operator.
Ext JS Interview Questions
Question 28. Once You Create An Object, You Can Add, Remove Or Change Properties Of That Object At Any Time?
Answer :
Yes. We can upload,remove or changer homes of created item at any time.
Question 29. When You Create A Function Inside Of A Method, What Does The “this” Keyword Refer To When Used In That Function?
Answer :
The “window” item, Inside of a function, the “this” key-word usually refers back to the window object. But whilst a funciton is a property of on object, the “this” key-word always refers to the object that the feature is a way of.
Var myObject =
shade : "red",
check : function()
feature testThis()
console.Log(this.Coloration); //undefined
console.Log(window === this); //genuine
;
testThis();
console.Log(this.Colour); //purple
console.Log(window === this); //fake
return "completed!"
;
myObject.Take a look at();
In the above example, the output in your JavaScript console need to be:
undefined
actual
pink
fake
“carried out!”
The purpose for the output is: The testThis feature inside of the myObject.Take a look at technique attempts to log the price of “this.Shade”. That feature is NOT a technique, it is only a feature statement, so “this” refers back to the window item. In this code, the window item, does now not have a “shade” belongings, so “this.Coloration” is undefined. Next, the testThis feature internal of the myObject.Check approach compares, window to the “this” key-word (just to prove the preceding factor). Again, due to the fact the testThis characteristic inside of the myObject.Test approach is NOT a way, it's far a assets of the window object, so “this” DOES identical the window object.
Next, the myObject.Check method tries to log the price of “this.Color”. Since the test metod is a property of the myObject item, and the myObject object has a belongings named “color”, the cost of that assets is logged to the console. Next, the myObject.Check method tries to compares window to the “this” key-word. Since the test metod is a property of the myObject object, the “this” keywork refers to the myObject item, and the contrast to the window item returns fake.
Question 30. Name Two Ways Two Change The Context Of A Javascript Method ?
Answer :
Use the call or observe strategies,
The call and follow techniques may be used to specify the context of any other method.
Var objectA =
call : "I am objectA",
sayName : characteristic()
alert("I am: " + this.Call);
,
objectB =
name : "objectB",
sayName : characteristic()
alert("I am: " + this.Call);
;
objectA.SayName.Name(objectB); //signals: "I am ObjectB"
objectB.SayName.Practice(objectA); //signals: "I am ObjectA"
Question 31. Can A Javascript Constructor Return A Primitive Value (e.G. A Number Or A String)?
Answer :
No. A JavaScript constructor can only return an object. When no return price is detailed, it returns an example of itself. If an item is certain because the go back value, then that item is the return price. If any fee aside from an object is precise because the go back cost, then it returns an example of itself.
Question 32. In Javascript, Are Objects Passed By Reference Or By Value?
Answer :
In JavaScript, all items are surpassed by way of reference. When you're making a exchange to a connection with an object, you change the real object. Primitive sorts are exceeded by way of fee.
Question 33. What Is The Difference Between A Constructor Function And A Non-constructor Function With Respect To The Word “this” ?
Answer :
In a non-constructor function, “this” refers to the worldwide context or if the characteristic is a way, it refers to the item to which the approach belongs. In the instance item that is again with the aid of a constructor characteristic, “this” refers to the example object itself.
Node.Js Interview Questions
Question 34. An Object Literal Can Be Used To Create Private Variables?
Answer :
False. Only features may be used in JavaScript to create privateness.
Question 35. What Is The Name Of The Object That Refers To The Application Used To View A Web Page?
Answer :
The “navigator” item
The object returned via the report.GetElementsByTagName() approach is an array.
False, The item again via the file.GetElementsByTagName() technique is an “HTMLCollection”. This is an array-like item that has a “length” property, may be enumerated, but isn't an real JavaScript array.
Question 36. Which Object.Property Combination Provides A Reference To The Protocol Used To View The Current Web Page?
Answer :
vicinity.Protocol
Koa.Js Interview Questions
Question 37. What Is The Difference Between Using Dot Notation And Bracket Notation When Accessing An Object’s Property?
Answer :
If the usage of dot notation, the assets ought to be a string and discuss with a assets that exists.
When using bracket notation, any legitimate JavaScript expression that produces a fee can be used in the brackets, along with a variable or an an array element.
Question 38. What Is Important To Remember About The Last Property’s Value In A Javascript Object Literal?
Answer :
The remaining property’s value must NOT be observed with the aid of a comma. Most browsers will permit you to break out with it if you neglect, however Microsoft Internet Explorer will bitch approximately the extra comma.
Question 39. What Are Two Ways In Which The Variable “foo” Can Be Assigned To An Empty Object?
Answer :
var foo = new Object();
var foo = ;
Question forty. When Using The Addeventlistener() Method To Create A Click-handler For A Dom Element, What Is The Value Of “this” Inside Of The Callback You Specify?
Answer :
The DOM detail that become clicked.
EmberJS Interview Questions

