Backbone Js Upwork Test

0
244

We don’t guarantee that all provided answers are correct.

How can he default sync handle map CRUD to REST?
Answer

  • create -> POST/collection
  • read -> GET/collection
  • update -> PUT/collection/id
  • All of the above

Backbone.sync, transforms the __ and __ operations into HTTP requests?
Answer

  • fetch(), save()
  • load(), save()
  • send(), save()
  • read(), save()

Backbone offers an opt-in for HTML5 pushState support.which one of the following is correct?
Answer

  • Backbone.history.push State
  • Backbone.window.push State
  • window.history.push State
  • Backbone.pushState State

What are the default Backbone.Sync handlers?
Answer

  • create, update, delete, read
  • create, update, trigger, delete, read
  • create, update, trigger, delete, read
  • create, update, delete, get

What is Backbone.sync is used for?
Answer

  • When Backbone wants to save or read a event to the server it
    calls out a function called as Backbone.sync
  • When Backbone wants to save or read a view to the server it calls
    out a function called as Backbone.sync
  • When Backt a function called as Backbone.sync
  • All of the above

Underscore is primarily used for its utility __ and json2.js?
Answer

  • Functions
  • Templates
  • Methods
  • Routers

Which of the following dependency must be added for Backbone.js setup?
Answer

  • <script src=”…/jquery.min.js”></script>
  • <script src=”…/angular.min.js”></script>
  • <script src=”…/underscore.min.js”></script>
  • <script src=”…/bootstrap.min.js”></script>

Which code is True about Backbone.Collection?
Answer

  • Var dotItem1 = new TodoItem();
    Var dotItem2 = new TodoItem();
    Var doList = [doItem1, doItem2];
  • Var dotItem1 = new TodoItem();
    Var dotItem2 = new TodoItem();
    Var doList = [doItem1, doItem2];
  • var TodoList = Backbone.Collection.extend({
    model: TodoItem
    });
    var todolist = new TodoList();
  • var TodoList = Backbone.Collection.extend({
    model: TodoItem
    });
    var todolist = TodoList();

Which of the following properties can be used for manipulating DOM element?
Answer

  • element
  • el
  • id
  • class

Which method can be used to create model?
Answer

  • new
  • extend
  • model
  • defaults

View are based on __ templates that provide layouts for regrading?
Answer

  • Model
  • View
  • Controller
  • Collection

Which options will you to auto-bind a BackboneJs view to existing element(s)?
Note: There may be more than one right answer.
Answer

  • $(“.same-class”).each(function(index,ele){
    var v = new MyView();
    $(ele).html(v.$el);
    });
  • $(“.same-class”).each(function(index,ele){
    var v = new MyView({el:$(ele)});
    });
  • var MyView = Backbone.View.extend({
    e1: ‘.class-name’,
    events:
    ‘hover .button’ : ‘test’
    },
    test: function(){
    console.log(‘h1’),
    }
    });
  • All of the above

In Backbonejs, how can you change templates of a view on the fly?
Answer

  • @company_location = new window.ArtistLocationForm
    ({templates:JST[“template/new_company_location”]})
  • render: function()
    { var templateFn = this.option.template || this.template;
    this.$el.html(templateFn(this.model.attributes));
    return this;
    }
  • render: function(){
    var templateFn = this.options.template ||
    this.template;
    this.$el.html(templateFn(this.model.attributes));
    return this;
  • @company_location= new window.ArtistLocationForm({
    template:JST[“template/new_company_location”]})

Which option below can be used when a collection/model is synced successfully with server?
Answer

  • “change:[attribute]”(model, value, options)
  • “destroy”(model, collection, options)
  • “request”(model_or_collection, xhr, options)
  • “sync”(model_or_collection, resp, options)

Which of the following syntax is valid in events for Backbone views?
Answer

  • “event css-selector” : “function”
  • “event element-id : “function”
  • “event” : “function”
  • All of the above

Which of the following methods can be called after all routers creation?
Answer

  • Backbone.history.start()
  • Backbone.history.start({pushState: true})
  • Backbone.history.start(true)
  • All of the above

Which of the following libraries provide event for Backbone views? (Choose all that apply)
Note: There may be more than one right answer.
Answer

  • Jquery
  • Angular
  • ZentoJS
  • All of the above

Which of the following event exists in Backbone Event Systems?
Answer

  • add
  • sync
  • invalid
  • All of the above

How can you use underscore Templates in Backbone.js views?
Answer

  • First, create an underscore template
  • Create div for el property using underscore
  • Compile the template using underscore
  • Load the compiled HTML into Backbone “e1”
  • All of the above

To create collection class of your own, extend Backbone.Collection, providing instance properties, as well as optional classProperties to be attached directly to the collection’s constructor function
………………….
Answer

  • model
  • extend
  • previous
  • hasChanged

You can remove all listeners on a particular object by using?
Answer

  • Instance_id.remove();
  • Instance_id.destroy();
  • Instance_id.off();
  • Instance_id.nulls();

How do you get only the first 20 items in a backbone collection?
Answer

  • collection.first(20)
  • first(collection, 20)
  • first.collection(20)
  • All of the above

Which of the following events is activated when the request to the server fails?
Answer

  • fail
  • error
  • catch
  • finally

Which of the following Collection method is equivalent to instantiating
a model with a hash of attributes?

Answer

  • create
  • new
  • init
  • intiate

Create a view that will build It’s own DOM element using the following code?
Answer

  • var myNewView = new LibraryView({model: thisBook, tagName: ‘ul’,
    className: ‘libraryview’,
    id: ‘library’,
    attributes: {‘data-date’ : new Date()}
    });
    console.log(myNewView.el);
  • var myNewView = new LibraryModel({view: thisBook, tagName: ‘ul’,
    className: ‘libraryview’,
    id: ‘library’,
    attributes: {‘data-date’ : new Date()}
    });
    console.log(myNewView.el);
  • var myNewView = new Librarymodel({view: thisBook, type: ‘ul’,
    className: ‘libraryview’,
    id: ‘library’,
    attributes: {‘data-date’ : new Date()}
    });
    console.log(myNewView.el);
  • None of the above

Which of the following is a built-in event in Backbone?
Answer

  • map
  • every
  • sort
  • each

Which of the following statements is correct about attaching Listeners to Events in a View?
Answer

  • Use the “events” attribute of Backbone.View.
    Remember that event listeners can only be attached to child elements of the “el” property
  • Use the “models” attribute of Backbone.View.
    Remember that event listeners can only be attached to child elements of the “el” property
  • Use the “routers” attribute of Backbone.View.
    Remember that event listeners can only be attached to child elements of the “el” property
  • Use the “collections” attribute of Backbone.View.
    Remember that event listeners can only be attached to child elements of the “el” property

Which of the following router methods is usually used while implementing login functionality?
Answer

  • init
  • auth
  • loggedIn
  • execute

How can a Backbone Model be created? Check all that apply.
Note: There may be more than one right answer.
Answer

  • var Todo = Backbone.Model.set({});
  • var Todo = Backbone.Model.create({});
  • var Todo = Backbone.Model.init({});
  • var Todo = Backbone.Model.extend({})

Backbone.sync is a _____ to synchronize your collections and models across the systems?
Answer

  • Call
  • Method
  • Testing
  • Event

Which code will you use when Defining a root route?

  • App.Route = Backbone.Router.extend({
    route: {
    ”: ‘index’
    },index: function(){
    $(document.body).append(“root index route”);
    }});
  • App.Router = Backbone.Router.extend({
    routes: {
    ”: ‘index’
    },index: function(){
    $(document.body).append(“root index route”);
    }});
  • App.Router = Backbone.Route.extend({
    route: {
    ”: ‘index’
    },index: function(){
    $(document.body).append(“root index route”);
    }});
  • All of the above

Which of the following template engines can be used with Backbone views?
Answer

  • EJS
  • Jade
  • Handlebars
  • All of the above

According to the code below, how can a model be removed from a collection and server?
var myCollection = new MyCollection();

var myModel = myCollection.get(2);

Answer

  • myCollection.remove(myModel)
  • myCollection.delete(myModel)
  • myCollection.destroy(myModel)
  • myModel.destroy()

You can limit the number of models in a Collection using the following code?
Answer

  • var myCollection = new Collection();
    myCollection.url = this.model.url() + ‘/slient’;
    myCollection.fetch();
  • var myCollection = new Collection();
    myCollection.url = this.model.url() + ‘/feed’;
    myCollection.fetch();
  • var myCollection = Backbone.Collection.extend({
    parse: function(response) {
    return response.slice(0,20);
    }
    });
  • All of the above

Which code gets index by Backbone.Collection?
var Items = Backbone.Collection.extend({
model : Item,
Url: “/Items”
})
var items = new Items;
items.fetch();
Answer

  • items.getindex(1);
  • items.get(0);
  • items.at(0);
  • items.index(1);

How can a set of models be retrieved from the server and into the collection when the arrive?
Answer

  • collection.retrive()
  • collection.get()
  • collection.getJSON(url)
  • collection.fetch()

Which of the following types can be used in templates?
Answer

  • JSON
  • String
  • Number
  • All of the above

Which of the following is not an underscore utility function over Collection?
Answer

  • foreach
  • groupby
  • length
  • size

Which code is true about Template Function call?
Answer

  • template
    class calc
    {
    public:
    T el;
    calc(T t);
    };
    template
    calc::calc(T t)
    { el = t;}
    double the_sum(calc &a, calc &b)
    {return a.el + b.el;}
  • template class calc
    {
    public:
    T el;
    calc(T t);
    ……….
    };
    template calc::calc(T t)(el =t;}
  • Both of the above
  • None of the above

Which code creates template in Backbone.js?
Answer

  • <table><thead><tr>
    <th>Name</th>
    <th>Aboutme</th>
    <th>Portfolio</th></tr>
    </thead>
    <tbody><% _.each(web, function(web) { %>
    <tr><td><%= web.get(‘name’) %></td>
    <td><%= web.get(‘aboutme’) %></td>
    <td><%= web.get(‘portfolio’) %></td></tr>
    <% }); %></tbody></table></script>
  • <table><thead><tr>
    <th>Name</th>
    <th>Aboutme</th>
    <th>Portfolio</th></tr></thead>
    <tbody><% _.each(web, function(web) { %>
    <tr><td><%= web.get(‘name’) %></td>
    <td><%= web.get(‘aboutme’) %></td>
    <td><%= web.get(‘portfolio’) %></td>
    </tr></tbody></table></script>
  • <table><thead><tr>
    <th>Name</th>
    <th>Aboutme</th>
    <th>Portfolio</th>
    </tr></thead><tbody>
    <% _.each(web, function(web) { %>
    <tr><td></td>
    <td><%= web.get(‘aboutme’) %></td>
    <td><%= web.get(‘portfolio’) %></td></tr>
    <% }); %></tbody></table></script>
  • <table><thead><tr>
    <th>Name</th>
    <th>Aboutme</th>
    <th>Portfolio</th>
    </tr></thead><tbody>
    <tr><td><%= web.get(‘name’) %></td>
    <td><%= web.get(‘aboutme’) %></td>
    <td><%= web.get(‘portfolio’) %></td>
    </tr>
    <% }); %></tbody></table></script>

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.