Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6923921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:35:52+00:00 2026-05-27T10:35:52+00:00

In an interview for some company, I was asked this question. What design patterns

  • 0

In an interview for some company, I was asked this question.

What design patterns do you know…then I was told to write simplest “hello world” application based on MVC Design Pattern.

I came up with a JavaScript program

var arr = ["a","b","c","d"];   // this is an array, same as store or model
alert(arr[0]);                // this is controller
//and browser alert is a view.

later I was told that alert is a view. The basic concept about MVC I know is any changes in Model are reported to View. And there is a controller in between to call the methods.

Can you correct my approach, or come up with an alternate solution for hello world MVC application. Also explain subtle aspects of MVC.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:35:52+00:00Added an answer on May 27, 2026 at 10:35 am
    var M = {}, V = {}, C = {};
    
    M.data = "hello world";
    
    V.render = function (M) { alert(M.data); }
    
    C.handleOnload = function () { V.render(M); }
    
    window.onload = C.handleOnLoad;
    

    Controller (C) listens on some kind of interaction/event stream. In this case it’s the page’s loading event.

    Model (M) is an abstraction of a data source.

    View (V) knows how to render data from the Model.

    The Controller tells to View to do something with something from the Model.

    In this example

    • the View knows nothing about the Model apart from it implements some interface
    • the Model knows nothing of the View and the Controller
    • the Controller knows about both the Model and the View and tells the View to go do something with the data from the Model.

    Note the above example is a severe simplification for demonstrating purposes. For real “hello world” examples in the JS MVC world go take a look at todoMVC

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was asked this question in some interview. I was required to write code
This is a question that I was asked on a job interview some time
This is a common interview question (according to some interview sites) but I can
This question was asked at interview.I need to have running total ( only using
I was asked this question in a .net/C# interview: If we have two threads
I recently had this question in an interview to write test cases to test
This is an interview question I saw on some site. It was mentioned that
I've encountered this interview question and would like some help in trying to understand
So I just got asked this at an interview today and after some googling
This is an interview question. There are some random numbers given (let's say in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.