Javascript Interview Questions Flashcards ionicons-v5-c

What is JavaScript?

A client-side scripting language. A high-level, prototype-based, dynamic, loosely-typed, and interpreted based programming language. Javascript can change HTML DOM content. attributes, hide elements, show elements.

Differences between Java and JavaScript?

- Java: object oriented, JS: object-based - Java: compiled, JS: interpreted - Java: Runs on browser/virtual machines, JS: runs on the browser only- Java: block based scope, JS: function based and object based scope.- Java: strongly typed, JS: weekly typed;- Java: static, JS: dynamic.- Java: objects are class based, JS: objects are prototype based

What are JavaScript Data Types?

These are dynamic Data Types (variables can hold multiple Data Types:- Strings- Numbers- Booleans- Arrays- Objects- Undefined- Null

Differentiate between JavaScript and ASP.net script?

- JS is a client-side scripting language, ASP.net: framework for running web applications- JS can be used together with ASP.net

Explain some features of JavaScript?

- light-weighted- client-side scripting language- interpreter based- event handling- validating user's input in DOM- supports in-built functions- looping statements- object-based- control statements- functional programming language

Explain the functionality of isNaN function?

isNaN function checks whether outputted value is NAN (not a number). ex: isNaN(856) //false, isNaN(true) //false, isNaN(NaN) //true

Name the founder/company who/that developed JavaScript?

A Netscape developer, Brendan Eich.

Write the syntax for hiding DOM elements in JavaScript?

For an element with the ID, "test":CSS:#test { display: none;}#test { opacity: 0;}HTML:document.getElementById("test").style.display = "none";<h1 style = "display: none">Hello world</h1>

How to use external JavaScript? What are its advantages?

JavaScript can place the <script></script> in the <head> or <body> tag.EXTERNAL JavaScript is time saving when the same code is used in different web pages because instead of writing it over can over, it can be linked just by: <script src="jsfile.js"></script>Advantages:- separates HTML and JS code to make it easier to read- speeds up web page loading- time saving

What are the possible ways to display Javascript output?

- innerHTML- innerText- document.write()-window.alert()-console.log()

What are JavaScript keywords?

Words reserved to identify the actions to be performed. Here are a few:- abstract- char- double- super- this- private-var- void- while- Boolean- false- Eval- Interface- Protected- Throw

What are JavaScript literals and Javascript variables?

In JS there are 2 types of values: kinds that are fixed, kinds which are variable true (can be changed). - Fixed values are called literals.- Variable values are called variables.Bonus: "Both Object Literals and Instance Objects have their place and purpose in JavaScript. The power of Object Literals is in their lightweight syntax, ease of use, and the facility with which they allow you to create name-spaced code. Instance Objects are powerful because they are derived from a function, they provide private scope when they are created, and expressions can be executed on instantiation."

Is JavaScript case-sensitive?

Yes, JS is case sensitive.

What are JavaScript identifiers?

JS identifiers are the name used to identify variables, keywords, functions. Javascript identifiers are case-sensitive.

What are Javascript type operators? ie operators used for returning data type of variable?

- typeof: returns the type of variable- instanceof: returns true if an object is an instance of an object type

Explain the difference between undefined and null value?

In Javascript, a variable without the value will be assigned as "undefined" value. The typeof will be "undefined" of ouch variable.Null means nothing, something that doesn't exist. The data type of null value is an object.ex: var person = null; typeof person //object null == undefined //true null === undefined //falseNull and undefined are equal in value, but not in type.

Write the syntax of declaring Javascript function and when do we use these functions

A function is a block of code written to perform a set of common tasks. They remove code repetition and code complexity.let functionName = (parameters) => { code goes here;};