Backbone.js Test Upwork

Suppose what are the typical problems you might face with the Backbone view code?

Between different view models are not shared

All of the above

Application pages are frequently refreshed from scratch from the server

Application models don’t change very often

What is Backbone.sync is used for?

When Backbone wants to save or read a event to the server it calls out a function called as Backbone.sync.

All of the above

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.

In Backbone.js, modelbinder class is used to make synchronization process of ............. and ............. together?

Views, models

Controller, views

Models, controller

State, models

Which of the following are Backbone Model object functions?

Note: There may be more than one right answer.

omit

key (s)

pick

value

Which code example can you use fetch with sending id?

var Type = Backbone.Model.extend({

url : "/api/SomeRoute"

});

var Type = Backbone.Model.extend({

urlRoot : "/api/SomeRoute"

});

Both of the above

None of the above



The sync method is called with which of the following parameters? (choose all that apply)

Note: There may be more than one right answer.

Method

Model

Options

None of the above

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

fetch(), save()

load(), save()

send(), save()

read(), save()

Which code can you use for the deleteLists?

deleteList: function() {

if (confirm(delete a list?')) {

bTask.views.activeListMenuItem.model.destroy();

}

return false;

}

deleteList: function() {

if (confirm(delete a list?')) {

bTask.views.activeListMenuItem.model.removeAll();

}

return false;

}

deleteList: function() {

if (confirm(delete a list?')) {

bTask.models.activeListMenuItem.model.destroy();

}

return false;

}

All of the above

Rather than adding or removing models individually, you might want to update an entire collection at once. ___ takes an array of models and performs the necessary add, remove, and change operations required to update the collection?

idAttribute

.attributes

Collection.set()

Collection.add()

Which method can be used to create a deep copy of the object?

duplicate

copy

clone

replicate

Which of the following iteration functions exist in Backbone Collections?

Note: There may be more than one right answer.

first

middle

last

All of these.

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

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

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

A Backbone view to a different DOM element, uses __, which will also create the cached $el reference and move the view's delegated events from the old element to the new one.

setElement

attributes

template

render

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

fail

error

catch

finally

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

init

auth

loggedIn

execute

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

Backbone.history.start()

Backbone.history.start({pushState: true})

Backbone.history.start(true)

All of the above

Which method enables History API?

Backbone.history.create();

Backbone.history.init();

Backbone.history.enable();

Backbone.history.start();

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

map

every

sort

each

Thorax provides an extended event _____ to simplify binding of common events from models and collections.

Hash

Listener

Key

Dispatch

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

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 method can be used to remove Models associations ?

clear

associate

reset

Non of the above

How can a Backbone Model be created? Check all that apply.

Note: There may be more than one right answer.

var Todo = Backbone.Model.set({});

var Todo = Backbone.Model.create({});

var Todo = Backbone.Model.init({});

var Todo = Backbone.Model.extend({})

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

collection.first(20)

first(collection, 20)

first.collection(20)

All of the above

Which option represents BackboneJS testing with jasmine when parameters are passed to fetch?

describe("People collection" function() {

var people = Backbone.Collection.extend({

});

function searchPeople(people, data ) {

people.fetch(data);

}

it("must verify the fetch parameters!", function(){

var param = {data : {gender : 'male'}};

spyOn(people, 'fetch').andReturn(); // Warning: this makes the call synchronous, Fetch actually won't go through!

searchPeople(people, param);

expect(people.fetch).toHaveBeenCalled();

expect(people.fetch).toHaveBeenCalledWith(param);

});

});

var Todo = Backbone.Model.extend({});

var todo1 = new Todo();

console.log(JSON.stringify(todo11));

var todo = new Todo({

title: 'Check the attributes of both model instances in the console.',

completed: true

});

var myCollection = new Collection();

myCollection.url = this.model.url() + '/feed';

myCollection.fetch();

All of the above

Unbinding function is used to remove the validation binding on the model and removing all events hooked up on the ................

Collection

Model

Router

State

How can the default sync handler map CRUD to REST?

create => POST /collection

read => GET /collection[/id]

update => PUT /collection/id

All of the above

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

Functions

Templates

Methods

Routers

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);

...

myCollection.remove(myModel)

myCollection.delete(myModel)

myCollection.destroy(myModel)

myModel.destroy()

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

EJS

Jade

Handlebars

All of the above

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

Call

Method

Testing

Event

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

"change:[attribute]"(model, value, options)

"destroy"(model, collection, options)

"request"(model_or_collection, xhr, options)

"sync"(model_or_collection, resp, options)

Which method can be used to create own Model?

new

extend

model

defaults

Which styles of variables are using Backbone in routers?

Note: There may be more than one right answer.

:params

*splats

#hashes

All of the above

Sync:Manages actual persistence by a function that Backbone calls every time it attempts to read or save a __ to the server?

Data

Model

Event

View

Which models can be created by extending Backbone?

var Todo = Backbone.Model.extend({});

var todo1 = new Todo();

console.log(JSON.stringify(todo11));

var todo2 = new Todo({

title: 'Check the attributes of both model instances in the console.',

completed: true

});

console.log(JSON.stringify(todo2));

var Todo = Backbone.Model.extend({});

var todo1 = new Todo();

console.log(JSON.stringify(todo1));

var todo2 = new Todo({

title: 'Check the attributes of both model instances in the console.',

completed: true

});

console.log(JSON.stringify(todo2));

var Todo = Backbone.Model.extend({});

var todo1 = new Todo();

console.log(JSON.stringify(todo11));

var todo = new Todo({

title: 'Check the attributes of both model instances in the console.',

completed: true

});

console.log(JSON.stringify(todo2));

All of the above

Backbone.js Test Answers part 2

Backbone.js Test Upwork 2019

