पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 20 के उत्तर और हल FliQi Question Bank app में।
भाषा
प्रश्न 1उत्तर + हल
हम अलर्ट बॉक्स में "Hello World" कैसे लिखते हैं?
How do we write "Hello World" in an alert box?
AalertBox("Hello World");
BmsgBox("Hello World");
Cmsg("Hello World");
Dalert("Hello World");
सही उत्तर / Answer: (D)
हल / Solution
जावास्क्रिप्ट में alert बॉक्स window ऑब्जेक्ट की alert() method से खुलता है। जो संदेश दिखाना हो, उसे quotes में argument बनाकर देते हैं, जैसे alert("Hello World"); इससे OK बटन वाला एक छोटा बॉक्स खुलता है। alertBox() और msg() जावास्क्रिप्ट में बने ही नहीं हैं, इसलिए इन्हें बुलाने पर त्रुटि आएगी। msgBox() VBScript का फ़ंक्शन है, जावास्क्रिप्ट का नहीं। इसलिए सिर्फ़ विकल्प 4 चलता है।
In JavaScript, an alert box is opened with the alert() method of the window object. The message is passed as a quoted string argument, as in alert("Hello World"); which shows a small box with an OK button. alertBox() and msg() are not built-in JavaScript functions, so calling them raises a ReferenceError. msgBox() belongs to VBScript, not JavaScript, which is why only option 4 works.
प्रश्न 2उत्तर + हल
जावास्क्रिप्ट में किसी फ़ंक्शन को परिभाषित करने का सबसे सामान्य तरीका ____ कीवर्ड का उपयोग करना है।
The most common way to define a function in JavaScript is by using the ____ keyword.
Afun
Bvar
Cfunction
Ddefine
सही उत्तर / Answer: (C)
हल / Solution
जावास्क्रिप्ट में फ़ंक्शन बनाने का सबसे आम तरीका function कीवर्ड है। पहले function लिखते हैं, फिर नाम, फिर कोष्ठक में parameters और अंत में { } के अंदर code, जैसे function add(a, b) { return a + b; }। fun जावास्क्रिप्ट का कीवर्ड नहीं है, यह Kotlin जैसी भाषा में चलता है। var से variable घोषित होता है, फ़ंक्शन नहीं। define भी जावास्क्रिप्ट का कोई कीवर्ड नहीं है।
The standard way to create a function in JavaScript is the function keyword. You write function, then the name, the parameters in parentheses and the body in braces, as in function add(a, b) { return a + b; }. fun is not a JavaScript keyword; it is used in languages such as Kotlin. var declares a variable, not a function, although a variable can hold one. define is not a JavaScript keyword at all.
प्रश्न 3उत्तर + हल
जावास्क्रिप्ट में किस प्रकार के पॉप-अप बॉक्स उपलब्ध हैं?
What types of pop-up boxes are available in JavaScript?
AAlert
BPrompt
CConfirm
DAll of these
सही उत्तर / Answer: (D)
हल / Solution
जावास्क्रिप्ट में तीन तरह के पॉप-अप बॉक्स होते हैं और तीनों window ऑब्जेक्ट की method हैं। alert() सिर्फ़ संदेश दिखाता है और OK दबाने तक रुकता है। confirm() में OK और Cancel होते हैं, और यह true या false लौटाता है। prompt() उपयोगकर्ता से text लेता है और वही string लौटाता है; Cancel दबाने पर null मिलता है। तीनों मौजूद हैं, इसलिए अकेला कोई एक विकल्प अधूरा है और सही उत्तर All of these है।
JavaScript offers three kinds of pop-up boxes, and all three are methods of the window object. alert() just shows a message and waits for OK. confirm() shows OK and Cancel and returns true or false. prompt() asks the user to type something and returns that string, or null if Cancel is pressed. Since all three exist, picking any single one would be incomplete, so the answer is "All of these".
प्रश्न 4उत्तर + हल
जावास्क्रिप्ट कोड को ___ का उपयोग करके कॉल किया जा सकता है।
JavaScript code can be called by using ___.
APreprocessor
BFunction/Method
CRMI
DTriggering Event
सही उत्तर / Answer: (B)
हल / Solution
जावास्क्रिप्ट में कोड का एक हिस्सा फ़ंक्शन या ऑब्जेक्ट की method में रखा जाता है। फिर उसके नाम से उसे बुलाया (call) जाता है, जैसे greet(); या document.write()। क्लिक जैसा ईवेंट भी आख़िर में किसी फ़ंक्शन, यानी event handler, को ही बुलाता है। इसलिए कोड बुलाने का असली ज़रिया फ़ंक्शन/method है। Preprocessor, C जैसी भाषाओं में compile से पहले का चरण है। RMI जावा में दूसरी मशीन की method बुलाने की तकनीक है।
In JavaScript, a piece of code is wrapped in a function or an object method and then run by calling it by name, as in greet(); or document.write(). Even an event such as a click ends up calling a function, the event handler, so the real mechanism is a function or method call. A preprocessor is a pre-compilation step in languages like C, and RMI is Java's way of invoking methods on another machine.
प्रश्न 5उत्तर + हल
getSelection() को कौन-सा कथन सबसे अच्छी तरह समझाता है?
Which best explains getSelection()?
AReturns the VALUE of a selected OPTION.
BReturns document.URL of the window in focus.
CReturns the value of cursor-selected text
DReturns the VALUE of a checked radio input.
सही उत्तर / Answer: (C)
हल / Solution
window.getSelection() उस text को लौटाता है जिसे उपयोगकर्ता ने cursor या mouse से चुना है। असल में यह एक Selection ऑब्जेक्ट देता है, और उस पर toString() लगाने से चुना हुआ text मिल जाता है। इसलिए विकल्प 3 सही है। किसी select सूची के चुने गए option की value select.value से मिलती है। पेज का URL document.URL या location.href से मिलता है। चुने हुए radio बटन की value उसके value गुण से पढ़ी जाती है।
window.getSelection() returns the text the user has highlighted with the cursor or mouse. Strictly it returns a Selection object, and calling toString() on it gives the selected text, so option 3 is correct. The value of a chosen option in a select list comes from select.value. The page address comes from document.URL or location.href. The value of a checked radio button is read from its value property, not from getSelection().
प्रश्न 6उत्तर + हल
बटन ऑब्जेक्ट में blur विधि का सिंटैक्स ____ है।
The syntax of the blur method in a button object is ____.
ABlur()
BBlur(contrast)
CBlur(value)
DBlur(depth)
सही उत्तर / Answer: (A)
हल / Solution
blur() विधि किसी तत्व, जैसे बटन, से फ़ोकस हटा देती है। यह focus() का उलटा काम करती है। इसे बिना किसी argument के बुलाते हैं, जैसे document.getElementById("btn").blur(); इसलिए सही सिंटैक्स blur() है। विकल्प 2, 3 और 4 में contrast, value और depth जैसे argument दिए गए हैं। blur() कोई argument लेती ही नहीं, इसलिए ये तीनों ग़लत हैं। CSS वाले blur फ़िल्टर से इसे मत मिलाइए।
The blur() method removes focus from an element such as a button, doing the opposite of focus(). It is called with no arguments, for example document.getElementById("btn").blur(); so the correct syntax is blur(). Options 2, 3 and 4 pass arguments such as contrast, value or depth, but blur() takes none, so all three are wrong. Do not confuse it with the CSS blur() filter, which does take a length.
प्रश्न 7उत्तर + हल
जब प्रपत्र (form) तत्व फ़ोकस खो देता है, तो निम्न में से कौन-सा ईवेंट सक्रिय होता है: <button>, <input>, <label>, <select>, <textarea>?
Which of the following events fires when a form element loses focus: <button>, <input>, <label>, <select>, <textarea>?
Aonfocus
Bonblur
Conclick
Dondblclick
सही उत्तर / Answer: (B)
हल / Solution
जब कोई form तत्व, जैसे textbox या select सूची, फ़ोकस खो देता है तब blur ईवेंट होता है। इसे onblur से पकड़ते हैं। उपयोगकर्ता Tab दबाकर या बाहर क्लिक करके आगे बढ़ता है, तभी यह चलता है। इसलिए भरे हुए खाने की तुरंत जाँच (validation) में यह बहुत काम आता है। onfocus इसका उलटा है, यह फ़ोकस मिलने पर चलता है। onclick एक क्लिक पर और ondblclick दो बार क्लिक करने पर चलता है।
The blur event fires when a form element such as a text box or select list loses focus, and onblur is the handler that catches it. It runs when the user presses Tab or clicks somewhere else, which makes it handy for validating a field right after it is filled. onfocus is the opposite, firing when the element gains focus. onclick fires on a single click and ondblclick on a double click, so neither is about losing focus.
प्रश्न 8उत्तर + हल
जावास्क्रिप्ट में कौन-सा वेरिएबल फ़ंक्शन आर्ग्युमेंट के रूप में काम करता है?
Which variable works as a function argument in JavaScript?
AFunction variable
BGlobal variable
CLocal variable
DObject variable
सही उत्तर / Answer: (C)
हल / Solution
फ़ंक्शन के कोष्ठक में लिखे parameters फ़ंक्शन के अंदर local variable की तरह काम करते हैं। जब फ़ंक्शन बुलाया जाता है, तब हर argument की value इन्हीं में आती है। जैसे function add(a, b) में a और b सिर्फ़ add के अंदर मौजूद रहते हैं और फ़ंक्शन ख़त्म होते ही मिट जाते हैं। Global variable फ़ंक्शन के बाहर घोषित होता है और हर जगह दिखता है। Function variable और Object variable जावास्क्रिप्ट में वेरिएबल के प्रकार नहीं हैं।
Parameters written inside a function's parentheses behave as local variables of that function. When the function is called, each argument value is copied into them. In function add(a, b), the names a and b exist only inside add and vanish when it returns. A global variable is declared outside every function and is visible everywhere. "Function variable" and "Object variable" are not variable kinds in JavaScript, so the answer is local variable.
प्रश्न 9उत्तर + हल
किसी सरणी में नया तत्व जोड़ने के लिए किस विधि का उपयोग किया जाता है?
Which method is used to add new element to an array?
AJoin()
BPush()
CPop()
DShift()
सही उत्तर / Answer: (B)
हल / Solution
push नया तत्व सरणी के अंत में जोड़ देता है और जोड़ने के बाद की नई लंबाई लौटाता है। एक बार में कई तत्व भी दिए जा सकते हैं। मूल सरणी ही बदलती है, नई सरणी नहीं बनती। pop अंतिम तत्व हटाता है और shift पहला तत्व, यानी दोनों घटाने का काम करते हैं। join सिर्फ़ तत्वों को जोड़कर स्ट्रिंग बनाता है, सरणी में कुछ जोड़ता नहीं।
push adds a new element at the end of the array and returns the new length after adding. Several elements can be passed in one call. It changes the original array rather than building a new one. The option pop removes the last element and shift removes the first one, so both take away instead of adding. The option join only builds a string, so push is the answer.
प्रश्न 10उत्तर + हल
कौन-सी विधि किसी सरणी से अंतिम तत्व को हटाती है?
Which method removes the last elements from an array?
AJoin()
BPush()
CPop()
DShift()
सही उत्तर / Answer: (C)
हल / Solution
pop सरणी के आख़िरी तत्व को निकाल देता है, उसकी लंबाई एक घटा देता है और निकाला हुआ तत्व लौटा भी देता है। ख़ाली सरणी पर चलाने से undefined मिलता है। shift भी तत्व हटाता है पर सबसे पहले वाला, आख़िरी वाला नहीं। push नया तत्व अंत में जोड़ता है और join सारे तत्व मिलाकर स्ट्रिंग बनाता है, इसलिए वे ग़लत हैं।
pop takes out the last element of an array, reduces its length by one and also returns the element that was removed. Running it on an empty array gives undefined. The option shift also removes an element, but the very first one rather than the last. The option push adds a new element at the end and join builds a string from all elements, so pop is correct.
आगे के 20 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति