Section 1

Preview this deck

List out the different ways an HTML element can be accessed in a Javascript code.

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (23)

Section 1

(23 cards)

List out the different ways an HTML element can be accessed in a Javascript code.

Front

Here are the list of ways an HTML element can be accessed in a Javascript code, (i) getElementById('idname'): Gets an element by its ID name (ii) getElementsByClass('classname'): Gets all the elements that have the given classname. (iii) getElementsByTagName('tagname'): Gets all the elements that have the given tag name. (iv) querySelector(): This function takes css style selector (like #id/.classname/tagname) and returns the first selected element. (v) querySelectorAll(): Similar to querySelector, this function returns a NodeList of html elements.

Back

What are the primitive data types in JavaScript?

Front

A primitive is a basic data type that's not built out of other data types. It can only represent one single value. All primitives are built-in data types by necessity, (the compiler has to know about them,) but not all built-in data types are primitives. In JavaScript there are 5 primitive data types are available they are undefined, null, boolean, string and number are available.Everything else in Javascript is an object.

Back

How do Javascript primitive/object types passed in functions?

Front

Primitive types in Javascript are passed by value; whereas, object types are passed by reference.

Back

What is splicing in JavaScript?

Front

Splicing arrays in JavaScript removes a certain part from an array to create a new array, made up from the part we took out. For example, if we wanted to remove the five numbers from the following array beginning from the 3rd index, we would do the following: var myArray = [0,1,2,3,4,5,6,7,8,9]; var splice = myArray.splice(3,7); console.log(splice); // will print out 3,4,5,6,7 console.log(myArray); // will print out 0,1,2,8,9

Back

What is the difference between innerHTML and innerText?

Front

innerHTML will process an HTML tag if found in a string, whereas innerText will not. For Example document.querySelector('p').innerHTML='one <br> two' gives the output one and two in two lines as <br> in html is a new line. Whereas document.querySelector('p').innerText='one <br> two' gives the output of the text as it is in one line.

Back

What is the difference between the operators '==' and '==='?

Front

The operator '==' compares the value; whereas, the operator '===' compares both value and type.

Back

What is NaN in Javascript?

Front

NaN is a short form of Not a Number. When a string or something else is being converted into a number and that cannot be done, then we get to see NaN. A strange thing about NaN is that it is not equal to anything including itself.

Back

What is DOM?

Front

DOM (Document Object Model) is an object-oriented representation of the HTML elements. All the elements (or nodes) are part of window.document.

Back

What is the difference between remove() and removeChild()?

Front

The remove() function just removes the element. Whereas, the removeChild() returns the deleted element.

Back

What is the difference between null and undefined?

Front

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.

Back

Execution type? Interpreted or Compiled?

Front

high-level, interpreted programming language. Dynamic

Back

What is a function callback?

Front

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.

Back

Explain the term closure.

Front

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

Back

Name the different types of pop up boxes in Javascript.

Front

There are three types of pop up boxes in Javascript (i) alert() provides some information to the user with just an OK button (ii) confirm() asks a question to the user with two options Ok and cancel, and (iii) prompt() takes an input from the user.

Back

What are the new ways to define a variable in Javascript?

Front

There are three possible ways of defining a variable in Javascript (i) var (which is used from the beginning) (ii) const (iii) let. The last two ways are the latest ways of defining a variable and are introduced in ES-2015(ES6 version).

Back

What does unshift() function do in Javascript?

Front

Just like push() which inserts elements into an array at the end of it, the unshift() function inserts elements at the beginning of an array.

Back

What is an Event Bubbling in Javascript?

Front

When an event is fired on an HTML element, the execution starts from that event and goes to its parent element. From there, the execution passes to its parent element and so on till the body element

Back

Name the two functions that are used to create an HTML element dynamically.

Front

To generate an html element dynamically, we need to use two functions: (i) var ele = createElement ('elementName'), which creates an element and (ii) parentElement.appendChild(ele)

Back

What is unshift method in JavaScript?

Front

The unshift method is used to insert a variable at the beginning of an array. var myArray = [1,2,3]; myArray.unshift(0); console.log(myArray); // will print out 0,1,2,3

Back

What are different types of Inheritence? Which Inheritance is followed in Javascript.

Front

There are two types of Inherientence in OOPS Classic and Prototypical Inheritance. Javascript follows Prototypical Inheritance.

Back

Explain the terms synchronous and asynchronous code.

Front

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.

Back

How is it possible to get the total number of arguments that are passed to a function?

Front

The arguments.length property helps in getting the total number of arguments that are passed to a function.

Back

What is the use of the 'this' keyword?

Front

The keyword 'this' refers to the current instance of the object when used inside a function. But, when used outside a function, it refers to the window object.

Back