October 13, 2018

Sreekanth B

IBM JavaScript Most Frequently Asked Latest Interview Questions Answers

What is the difference between null and undefined?

When used the typeof operator on null; i.e., typeof(null), the value is an object. Whereas, when used the typeof operator on undefined; i.e., typeof(undefined), the value would be undefined.

Are Javascript and JScript the same?

No, Javascript was provided by Netscape; whereas, JScript was provided by Microsoft.

Are Typescript and Javascript the same?

Typescript is not the next version of Javascript but is developed by Microsoft and can be taken as a superset to Javascript; the code written in Typescript is later compiled into Javascript. Typescript adds new features like Interfaces, Generics, etc.
IBM JavaScript Most Frequently Asked Latest Interview Questions Answers
IBM JavaScript Most Frequently Asked Latest Interview Questions Answers

Name some of the Javascript frameworks.

There are many Javascript Frameworks available today, but the most commonly used frameworks are:

(i) Angular (ii) React (iii) Vue

Explain the typeof operator.

The operator typeof is an example of Unary Operators, which is used by placing it before its operand; which can be of any type.

What are anonymous functions in Javascript?

An anonymous function allows a developer to create a function that has no name. In other words, anonymous functions can be used to store a bit of functionality in a variable and pass that piece of functionality around.

What is the difference between an Anonymous Function and a named function?

Anonymous functions exist only after they are called; whereas, Named functions to exist even if not called.

What are self Executing Functions?

These functions are executed right after its definition.  Also called as Immediately Invoked Function Expressions (IIFE's). Syntax:
(function(){
    console.log('in iffe');
})()

What is a function callback?

The callback function is a mechanism to send one function to another function as an argument; i.e., passing func as an argument to another function.

What happens when the recursion calling is applied on two functions?

The calling of recursion is possible in two functions, but the call comes to an end after some time.

Explain the term closure.

The inner functions can be called as closure when it has access to the outer function's variables.

Explain the terms synchronous and asynchronous code.

The synchronous code is something that should be finished before anything else can happen, or in other words, the synchronous code is blocking. And the Asynchronous code is something in which actions can happen and is not dependent on other actions- in other words, it is non-blocking.

How do you add an element at the begining of an array? How do you add one at the end?

var myArray = ['a', 'b', 'c', 'd'];
myArray.push('end');
myArray.unshift('start');
console.log(myArray); // ["start", "a", "b", "c", "d", "end"]
With ES6, one can use the spread operator:

myArray = ['start', ...myArray];
myArray = [...myArray, 'end'];
Or, in short:

myArray = ['start', ...myArray, 'end'];

Imagine you have this code:

var a = [1, 2, 3];
a) Will this result in a crash?

a[10] = 99;
b) What will this output?

console.log(a[6]);

a) It will not crash. The JavaScript engine will make array slots 3 through 9 be “empty slots.”

b) Here, a[6] will output undefined, but the slot still remains empty rather than filled with undefined. This may be an important nuance in some cases. For example, when using map(), empty slots will remain empty in map()’s output, but undefined slots will be remapped using the function passed to it:

var b = [undefined];
b[2] = 1;
console.log(b);             // (3) [undefined, empty × 1, 1]
console.log(b.map(e => 7)); // (3) [7,         empty × 1, 7]

What is the value of typeof undefined == typeof NULL?

The expression will be evaluated to true, since NULL will be treated as any other undefined variable.

Note: JavaScript is case-sensitive and here we are using NULL instead of null.

What would following code return?

console.log(typeof typeof 1);

string

typeof 1 will return "number" and typeof "number" will return string.

What will the following code output and why?

var b = 1;
function outer(){
    var b = 2
    function inner(){
        b++;
        var b = 3;
        console.log(b)
    }
    inner();
}
outer();

Output to the console will be “3”.

There are three closures in the example, each with it’s own var b declaration. When a variable is invoked closures will be checked in order from local to global until an instance is found. Since the inner closure has a b variable of its own, that is what will be output.

Furthermore, due to hoisting the code in inner will be interpreted as follows:

function inner () {
    var b; // b is undefined
    b++; // b is NaN
    b = 3; // b is 3
    console.log(b); // output "3"
}

What is Ajax?

Ajax is abbreviated as Asynchronous Javascript and XML. It is new technique used to create better, faster and more interactive web systems or applications. Ajax uses asynchronous data transfer between the Browser and the web server.

This technique is used to make internet faster and user friendly. It is not a programming language.

What are the disadvantages of Ajax?

Following are the disadvantages of Ajax:

AJAX is dependent on Javascript. If there is some Javascript problem with the browser or in the OS, Ajax will not support
Ajax can be problematic in Search engines as it uses Javascript for most of its parts.
Source code written in AJAX is easily human readable. There will be some security issues in Ajax.
 Debugging is difficult
 Increases size of the requests
 Slow and unreliable network connection.
Problem with browser back button when using AJAX enabled pages.

What is update panel?

Update panel  is a server control used to update the specified portion of a web page. Script Manager needs to be used whenever update panel is used. Using update panel, user cannot handle outside controls.

Which are the two methods used for cross domain Ajax calls?

There are two methods used to transfer data between the two more more security domains:

CORS – Cross Origin Resource Sharing and it works with the HTTP web browsers
JSONP – JSON with Padding which works with the HTTP GET and on legacy browsers.

Subscribe to get more Posts :