All the Front End developers, UI/ UX developers and designers will find these questions extremely useful. All freshers, BCA, BE, BTech, MCA and college students wanting to make a career in front end designing will be highly benefitted by these questions.
Global Variables - A global variable has global scope which means it can be accessible from anywhere in your code.
'This' keyword refers to the object from where it was called.
7. What is the difference between the operators ‘==’ & ‘===‘?
== operator makes type correction and automatically converts one type into another and return value based upon content equality.
=== operator supports strict equality and only return true if both variables are of same type and also contain same value.
‘NULL’ implies no value or no object. It can be assigned to a variable as a representation of no value.
10. What is the difference between undeclared and undefined?
Undeclared variables are those that are not initialized or declared. If you try to get 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 assigned with any value. If you try to get the value of an undefined variable, an undefined value is returned.
11. What is the difference between innerHTML and innerText?
innerHTML- It interprets an HTML tag if found in a string as HTML and sets the same content in HTML format.
innerText - It interprets an HTML tag as text and sets the content of the tag as plain text.
Event Bubbling is a technique in which the event is first captured and handled by the target element and then propagated to parent elements until it reaches the document object.
In the above example, when a click event happens on <span>, it first runs the handlers on <span> followed by on the outer <div> and then on the outer <body>.
NaN is a special value that denotes Not-a-Number and cannot be represented as a meaningful number. There are many ways in which NaN can happen such as dividing zero by zero, converting a non-numeric string into a number etc.
We can use isNan() function to see if a value is an NaN value. The function returns true if the argument passed is not a number otherwise it returns false.
14. What is break and continue statements?
Break statement is used to jump out of current loop without executing loop statement(s) below it.
Continue statement skips the rest of the loop statement(s) and continues with the next iteration in the loop.
15. What is the use of typeof operator?
typeof is an operator that returns string description of the operand indicating it's data type.
There are three types of errors:
Run-time errors: These errors occur during execution while the program is running. For example, division of a number by zero, calling invalid functions etc.
Logical error: There errors occur when you make a mistake in the logic. Your program compiles and runs without error but doesn't produce intended result. They are hard to determine and debug as they tend to be hidden in the source code.
To enable strict mode, write "use strict" at the top of the script.
19. What is the difference between ‘null’ and ‘undefined’?
Both the keywords signify absence of value.
The differences are:
'null' is a special value represents 'no value'. 'null' can be assigned to a variable that signifies that we have defined a variable but have not assigned any value yet.