JavaScript Multiple choices


Total available count: 50
Subject - JavaScript Frameworks
Subsubject - JavaScript

var data = [ "X" ];data.push( "S" );data.push( "D", "E" );What is result of data?


 

 

 

 



D


Solution:-

JavaScript Array push() Method Definition and Usage

The push() method adds new items to the end of an array and returns the new length.

Note: The new item(s) will be added at the end of the array and the method changes the length of the array.

Tip: Using the unshift() method we can add items at the beginning of an array.

JavaScript Array push() Method Syntax:

array.push(item1, item2, ..., itemX)

JavaScript Array push() Method Example:
Add a new item to an array:

var courses = ["HTML", "SQL", "Oracle", "CSS"];
courses.push("Javascript");

The output is as below:

HTML, SQL, Oracle, "CSS, Javascript

 




Next 5 multiple choice(s)

1

var data = [ "X" ];data.unshift( "S" );data.unshift( "D", "E" ); What is result of data?

2

var data = [ "X", "Y", "Z" ];data.pop(); What is the output of this code?

3

var data = [ "X", "Y", "Z" ];data.shift(); What is the output of this code?

4

Pick the difference between pop() and shift() methods in JavaScript?

5

Escape characters are not used along with which characters in JavaScript?

Comments