Interview Questions Flashcards

1
Q

What is the DOM?

A

DOM stands for Document Object Model. It is a representation of the HTML document displayed in a window. Objects are organized in a hierarchy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is ECMAScript and how does it relate to JavaScript?

A

ECMA is a standardized specification for scripting languages; JavaScript is a scripting language based on ECMA specification.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is JavaScript?

A

JavaScript is a programming/scripting language that allows you to implement complex logic on web pages;

JavaScript is lightweight and interpreted programming language. It is most commonly utilized by client-side technologies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are some advantages that can be gained through using JavaScript

A

Less server interaction - Allows for client-side validation of user-input, reducing the number of unsuccessful HTTP requests.

Increased Interactivity - The Document Object Model can be manipulated based on different events initiated by the user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does it mean that JavaScript is loosely typed?

A

This means that JavaScript does not require you to specify a type when declaring a variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does it mean that JavaScript is an interpreted language?

A

This means that JavaScript is not pre-compiled. It is read line by line by the browser.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What tag would you use to wrap around a block of JavaScript on an HTML document and where would you need to place it?

A

Use the tag to wrap the JavaScript statement, and make sure the block is nested within the body of the HTML document.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Is JavaScript case sensitive?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you insert a comment in JavaScript?

A
// - Single-Line comment
/*
* Multi-line comment
*/
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Does Javascript have data types? If it does, what are they?

A

Yes, and they are Boolean, Null, Undefined, Number, String, Object, Symbol, and Function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are three different ways you can create variables in Javascript and when would you use each?

A

var - scope of the variable is its current execution context
let - scope of the variable is limited to the block in which it is created
const - scope of const is similar to let statement, but once assigned a value, it cannot be changed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are global variables? How are these variables declared and what are the problems associated with using them?

A

Global variables are those that are available throughout the length of the code.

Global variables are created when the variables are declared outside of any block

Global variables make it hard to debug and test code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What Javascript values are considered falsey? What are considered truthy?

A

Falsey Values:

  • undefined
  • null
  • NaN
  • false
  • ” “(empty string)
  • 0

everything else is truthy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are undeclared and undefined variables?

A

Undeclared variables are those that do not exist in a program, and if called gives a “reference not found” error

Undefined variables are those that are declared but have not been initialized with a value, and if called gives a “undefined” error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is === operator vs == operator?

A
== double equals will perform a type conversion;
=== triple equals will not perform a type conversion, and will return false if the types are different
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the typeof operator?

A

an operator that returns a string indicating the type of the unevaluated operand

17
Q

What is hoisting in Javascript?

A

a Javascript mechanism where variables and function declarations are moved to the top of their scope before code execution

18
Q

What are anonymous functions?

A

Anonymous functions are functions that are dynamically declared at runtime. They are not given a name in the same way as normal functions

19
Q

What is an IIFE?

A

an Immediately Invoked Function Expression that runs as soon as it is defined

20
Q

How can you add new elements dynamically?

A

Using functions like document.createElement() and specifying a DOM tag. You can also use appendChild() on that element to add a Node beneath your newly created element

21
Q

Explain how you can submit a form using Javascript?

A

To submit a form using Javascript use document.getElementById(“myform”).submit()

22
Q

What is an event?

A

an event is an action that takes place on the DOM, like mouse click or tapping keyboard, etc

23
Q

What are some common Javascript events?

A

onchange, onclick, onmouseover, onmouseout, onload, etc

24
Q

What is an event listener?

A

Event listeners are procedures or functions that wait for an event to occur, method ex: addEventListener

25
Q

What is JSON?

A

Javascript Object Notation. A safe and reliable data interchange format in Javascript, which is easy to understand for both users and machines

26
Q

What is Ajax?

A

an abbreviation of Asynchronous Javascript and XML. Uses the XMLHttpRequest object to send and receive information with the server in formats up-to and including JSON, XML, HTML, and text files.

27
Q

What are advantages of Ajax?

A
  • Faster retrieval of data because its asynchronous
  • Reduced Bandwidth usage and increased speed
  • Improved User Experience
28
Q

What are disadvantages of Ajax?

A
  • Browser Incompatibility
  • Ajax is dependent on Javascript. If there’s a Javascript problem with the browser, Ajax will not be supported
  • slow and unreliable network connection
29
Q

What is the for-in loop in Javascript?

A

this loop iterates over the enumerable properties of an object.

30
Q

What is the for-of loop in Javascript?

A

this loop iterates over iterable objects, like Strings and Arrays

31
Q

What is the use of isNaN function?

A

this function returns true if the argument is not a number otherwise it is false

32
Q

What is negative infinity?

A

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

33
Q

What are of the rules that Javascript variables names must conform to?

A

Cannot delare a variable name that is a reserved Javascript keyword. Names must begin with a letter or an underscrore

34
Q

Explain the working of timers in Javascript? Also discuss the drawbacks of using the timer, if any?

A
  • Timers are used to execute a piece of code at a set time or also to repeat the code in a given interval of time. functions include setTimeout, setInterval, and clearInterval
  • Timers are operated within a single thread, and thus events might queue up, waiting to be executed
35
Q

What does JSON.parse() do?

A

it turns a Javascript string formatted as JSON into a Javascript object

36
Q

What does JSON.stringify do?

A

To send a javascript object as a json, we need to turn it into a string.