Using JavaScript and JSON in Django | Week 2

Course Name: Django for Everybody

Sub-course: Using JavaScript and JSON in Django

Course Link: Django for Everybody

Sub-course Link: Django Features and Libraries

These are Using JavaScript and JSON in Django Week 2 Answers Coursera Quiz


JavaScript OO

Q1. Which of the following is a template that defines the shape of an object that is created?

  • Message
  • Inheritance
  • Method
  • Instance
  • Class

Answer: Class


Q2. Which of the following describes a feature which we would expect from a programming language that supported first class functions?

  • The ability to return a value from a function
  • The ability to have a variable number of parameters when calling a function
  • The ability to define a function and assign the function to a variable
  • The ability to omit parameters and have the omitted parameters default to a value
  • The ability for a function not to return a value (i.e., void functions)

Answer: The ability to define a function and assign the function to a variable


These are Using JavaScript and JSON in Django Week 2 Answers Coursera Quiz


Q3. What keyword / predefined variable is used in a JavaScript class definition to refer to the “current instance” of the class?

  • $this
  • _self
  • self
  • this
  • me

Answer: this


Q4. What do these two statements in JavaScript accomplish?
data.stuff = “hello”; data[‘stuff’] = “hello”;

  • These two statements accomplish the same thing
  • The first statement creates an object and the second creates a dictionary
  • The first statement is a syntax error in JavaScript
  • The second statement is a syntax error in JavaScript

Answer: These two statements accomplish the same thing


These are Using JavaScript and JSON in Django Week 2 Answers Coursera Quiz

See also  Building Web Applications in Django | Week 4

Q5. How is the constructor defined in a JavaScript class compared to how the constructor is defined in a Python class?

  • The Python constructor method is called _construct() and the JavaScript constructor method is called construct()
  • A Python constructor is a method named init() and a JavaScript constructor is code in the outer function definition
  • The Python and JavaScript constructor patterns are the same
  • JavaScript does not support the notion of running a “constructor” when objects are created

Answer: A Python constructor is a method named init() and a JavaScript constructor is code in the outer function definition


These are Using JavaScript and JSON in Django Week 2 Answers Coursera Quiz


More Weeks of this course: Click Here

More Coursera Courses: http://progiez.com/coursera


Using JavaScript and JSON in Django Week 2 Answers