Common JS Tech Interview Questions

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What is 'this' keyword in JavaScript?

'This' keyword refers to the object from where it was called.

Write the code for adding new elements dynamically?

1. If adding to a div or part you may need to get that element via document.getElementById/ClassName or querySelector and store it in a variable. 2. To make the new element use the document.createElement('ie div/p/a') and store that in a variable. 3. Add content to the new element, by accessing the new element variable and using .innerHTML/.createTextNode or other methods. 4. Append the new element to the appropriate spot via document.elementToAddTo.appendChild(newElem); can add to the end by doing document.body.appendChild(new elem)

What is a prompt box?

A prompt box is a box that allows the user to enter input by providing a text box. A label and box will be provided to enter the text or number.

What are global variables? How are these variable declared?

Global variables are available throughout the length of the code so that it has no scope. The var keyword is used to declare a local variable or object. If the var keyword is omitted, a global variable is declared. Example: // Declare a global: globalVariable = "Test"; The problems faced by using global variables are the clash of variable names of local and global scope. Also, it is difficult to debug and test the code that relies on global variables.

Enumerate the differences between Java and JavaScript?

Java is a complete programming language. In contrast, JavaScript is a coded program that can be introduced to HTML pages. These two languages are not at all inter-dependent and are designed for different intent. Java is an object-oriented programming (OOPS) or structured programming languages like C++ or C, whereas JavaScript is a client-side scripting language.

What is JavaScript?

JavaScript is a client-side and server-side scripting language inserted into HTML pages and is understood by web browsers. JavaScript is also an Object-based Programming language

Which is faster between JavaScript and an ASP script?

JavaScript is faster. JavaScript is a client-side language,, and thus it does not need the assistance of the webserver to execute. On the other hand, ASP is a server-side language and hence is always slower than JavaScript. Javascript now is also a server-side language (nodejs).

What is negative Infinity?

Negative Infinity is a number in JavaScript which can be derived by dividing negative number by zero.

Which company developed JavaScript?

Netscape is the software company that developed JavaScript.

What is the use of isNaN function?

isNan function returns true if the argument is not a number; otherwise, it is false.

What are JavaScript Data Types?

- Number - String - Boolean - Object - Undefined

Is it possible to break JavaScript Code into several lines?

Breaking within a string statement can be done by using a backslash, '\,' at the end of the first line. Example: document. Write ("This is \a program,"); And if you change to a new line when not within a string statement, then javaScript ignores the break in the line.

What are undeclared and undefined variables?

Undeclared variables are those that do not exist in a program and are not declared. If the program tries to read the value of an undeclared variable, then a runtime error is encountered. Undefined variables are those that are declared in the program but have not been given any value. If the program tries to read the value of an undefined variable, an undefined value is returned.


Kaugnay na mga set ng pag-aaral

Chapter 12: Epidemiology (Stanhope: Public Health Nursing, 8th Ed)

View Set

Chapter 41: Gastrointestinal Dysfunction

View Set

Nursing Fundamentals I Final Exam

View Set

anatomy 2 ch 18 blood, hemostasis, blood groups

View Set