Movatterモバイル変換


[0]ホーム

URL:


Menu
×
See More 
Sign In
+1 Get Certified Upgrade Teachers Spaces Bootcamps Get Certified Upgrade Teachers Spaces Bootcamps
   ❮     
     ❯   

Basic JavaScript

JS TutorialJS SyntaxJS VariablesJS OperatorsJS If ConditionsJS LoopsJS StringsJS NumbersJS FunctionsJS ObjectsJS ScopeJS DatesJS Temporal DatesJS ArraysJS SetsJS MapsJS IterationsJS MathJS RegExpJS DestructuringJS Data TypesJS ErrorsJS DebuggingJS ConventionsJS ReferencesJS 2026JS Versions

JS HTML

JS HTML DOMJS EventsJS ProjectsNew

JS Advanced

JS FunctionsJS ObjectsJS ClassesJS AsynchronousJS ModulesJS Meta & ProxyJS Typed ArraysJS DOM NavigationJS WindowsJS Web APIsJS AJAXJS JSONJS jQueryJS GraphicsJS ExamplesJS Reference


JavaScript Functions Quiz

Test Yourself

Test your knowledge of JavaScript functions.

This quiz uses the same examples you learned in the tutorial chapters.

Question 1

What is returned in the text variable?

function sayHello() {
  return "Hello World";
}

let text = sayHello();
  • A. sayHello
  • B. Hello World
  • C. undefined

Question 2

Which line calls the function?

function test() {
  return 5;
}

let x = test;
let y = test();
  • A. function test() { }
  • B. let x = test;
  • C. let y = test();

Question 3

In the function below, what area andb?

function multiply(a, b) {
  return a * b;
}
  • A. Arguments
  • B. Parameters
  • C. Return values


Question 4

What is returned by this function call?

function add(a, b) {
  return a + b;
}

add(2, 3) * 10;
  • A. 5
  • B. 10
  • C. 50

Question 5

What value is returned if a function has noreturn statement?

  • A. null
  • B. false
  • C. undefined

Question 6

Which type of function can be called before it is defined?

  • A. Function declaration
  • B. Function expression
  • C. Arrow function

Question 7

Which arrow function is correct?

  • A. const add = (a, b) => return a + b;
  • B. const add = a, b => a + b;
  • C. const add = (a, b) => a + b;

Question 8

What doesthis refer to inside an object method?

const person = {
  name: "John",
  getName: function() {
    return this.name;
  }
};
  • A. The function itself
  • B. The global object
  • C. The object that owns the method

Question 9

Why does this code not work as expected?

const person = {
  name: "John",
  greet: () => this.name
};
  • A. Arrow functions cannot return values
  • B. Arrow functions do not have their ownthis
  • C. The object syntax is wrong

Answers


Question 1

Answer: B.

Explanation: The function returns the string"Hello World".

Question 2

Answer: C.

Explanation: Parentheses() execute the function.

Question 3

Answer: B.

Explanation: Parameters are the names listed in the function definition.

Question 4

Answer: C.

Explanation: The function returns 5, then it is multiplied by 10.

Question 5

Answer: C.

Explanation: Functions withoutreturn returnundefined.

Question 6

Answer: A.

Explanation: Function declarations are hoisted.

Question 7

Answer: C.

Explanation: Arrow functions return expressions withoutreturn when written on one line.

Question 8

Answer: C.

Explanation: In a method,this refers to the owner object.

Answer: C.

Explanation: In a method,this refers to the owner object.

Question 9

Answer: B.

Explanation: Arrow functions inheritthis from their surrounding scope.


Quiz Result

If you answered most questions correctly, you have a solid understanding of JavaScript functions.

If not, revisit the chapters and try again.

Back to JavaScript Functions.


Note

Understanding functions is essential for mastering JavaScript.

Practice writing your own functions to improve faster.



×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted ourterms of use,cookies andprivacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved.W3Schools is Powered by W3.CSS.

-->
[8]ページ先頭

©2009-2026 Movatter.jp