About JavaScript Basic
Defining JavaScript
JavaScript is a scripting or a programming language, allowing developers to perform complex features on web pages. Initially, this language was created for making web pages alive. In JavaScript, the programs are called scripts. One can write them in the HTML of a web page, then it will automatically run once the page loads. At this point, JavaScript is completely different from another language, called Java.
Initially, when JavaScript was created, it was called “LiveScript”. Then, as Java was extremely popular in that period, then it was decided to call it JavaScript to position it relative to Java. But, over the years, JavaScript has transformed into a completely independent language, with its specification, known as ECMAscript, having no relation to Java. Modern JavaScript can both work in the browser and on the server. Basically, it can run on any device that has a specific program known as the JavaScript engine.
JavaScript Introduction
What is JavaScript?
JavaScript is a high-level, dynamic, lightweight, interpreted computer programming language. It’s designed for creating network-centric apps. It has made modern web apps possible— apps with which you can interact directly without doing a page reload for every action. It’s also used in more traditional websites to provide different forms of interactivity and cleverness.
JavaScript is mostly used as a part of web pages. Implementations of JavaScript allow client-side script to interact with the user and make dynamic web pages.
Things that make JavaScript great and unique:
Full integration with HTML/CSS
Simple things are done simply
All major browsers support and enabled by default
JavaScript is the only browser technology that includes these three points. Now you understand why it’s the most widespread and powerful tool for creating browser interfaces. JavaScript helps to create servers, mobile applications, games, etc.
Apply Link For JavaScript Basic
Apply Link For JavaScript Quiz
Start Quiz
Test your knowledge with W3docs’ basic quiz made especially for beginners in Javascript. Pass the test and get a Certificate of achievement!
The Test
The test contains 20 questions and there is no time limit. The test is not official, it’s just a nice way to see how much you know about Javascript.
Count Your Score
You will get 5% for each correct answer. At the end of the Quiz, your total score will be displayed out of 100% maximum score.
Enrich your knowledge
At the end of the quiz you can see all the questions with the right answers. There will also be notes about the answers which will lead you to the appropriate page on the platform to enrich your knowledge. Read our HTML tutorial if you are not sure that you are ready for the quiz.
Quiz Answers
How do you write “Hello W3docs” in an alert box?
alertBox(“Hello W3docs”);
alert(“Hello W3docs”);
msg(“Hello W3docs”);
msgBox(“Hello W3docs”);
modal(“Hello W3docs”)
Ans. alert(“Hello W3docs”);
Which is the correct way to write a comment in JavaScript?
Ans. //….
How can you detect the application name of the client’s browser?
navigator.appName
navigator.browserName
browser.name
Ans. navigator.appName
Which one of the following is correct?
i =+ 1;
i += 1;
i = i++1;
+i+;
Ans. i+=1;
Which array method sorts the elements of an array?
sort()
changeOrder(order)
order()
None of the above metjods
Ans. sort()
How do you round the number 5.35 to the nearest integer?
rnd(5.35)
Math.rnd(5.35)
round(5.35)
Math.round(5.35)
Ans. Math.round(5.35)
How do you get cookies in JavaScript?
window.cookies
location.cookies
document.cookie
document.cookies
Ans. document.cookie
How do you write anything into the web page in JavaScript?
window.write(…)
document.write(…)
window.page.write(…)
document.page.write(…)
Ans. document.write(…)
How do you create a new function in JavaScript?
new.function() {}
function myFunction() {}
function:myFunction() {}
function = myFunction() {}
Ans. function myFunction() {}
var1 = ’12’;
if ( var2 ) {
delete var2;
}
else if ( var1 ) {
delete var1;
}
None
both
only var1
only var2
Ans. Both
The JavaScript Date is fundamentally specified as _
The number of milliseconds elapsed since January 1, 1970
The number of picoseconds elapsed since January 1, 1970
The number of minutes elapsed since January 1, 1980
The number of days that have elapsed since January 1, 1980
Ans. The number of milliseconds elapsed since January 1, 1970
Which of the following is the correct syntax for opening a new window called “w3docs”?
w3docs = window.open.new(“http://www.w3docs.com”);
w3docs = window.new(“http://www.w3docs.com”);
w3docs = window.open(“http://www.w3docs.com”);
w3docs = window(“http://www.w3docs.com”);
Ans. w3docs = window.open(“http://www.w3docs.com”);
Which of the following is the correct way to write an array?
let fruits = new Array(1:”apple”,2:”peach”,3:”banana”);
let fruits = new Array:1=(” apple “)2=(“peach”)3=(“banana”);
let fruits = new Array(“apple “,”peach”,”banana”);
let fruits = new Array=”apple”,”peach”,”banana”;
Ans. let fruits = new Array(“apple “,”peach”,”banana”);
The pop() method removes the last item from an array and returns a new array.
False
True
Ans. False
let stringToNum=parseInt(“123ab”)
123
Exception
123ab
NaN
Ans. 123
Which are closures?
Variables
Objects
Functions
All of the above options
Ans. All of the above options
Which of the following options is the opposite of the lexical scoping?
Literal scoping
Dynamic scoping
Generic scoping
Static scoping
Ans. Dynamic scoping
Which of the following options is right for dynamic scoping?
Variables can be declared outside the scope
Variables cannot be declared outside the scope
Variables must be declared outside the scope
None of the mentioned
Ans. Variables can be declared outside the scope
What will be the output of the following statement?
let total=eval(“10*10+8”);
10*10+8
108 as an integer value
108 as a string
Exception is thrown
Ans. 108 as an integer value
What will happen if the return statement doesn’t have the associated expression?
It will throw an exception
It will return 0
It will return undefined
None of the above options
Ans. It will return undefined