YouTube Icon

Interview Questions.

Top 10 Backbone.js Interview Questions and Answers - May 20, 2022

fluid

Top 10 Backbone.js Interview Questions and Answers

Q1. Make sense of How You Can Use Backbone.js For Multiple Page Web App?
For different page web application in backbone.js there are loads of thought however the following are two which can be valuable.

Serving the page : In this, where you need to have your web server course everything to the server course all that to serve a similar static page. That me that everything in http://wisdomjobs.com/* will serve/var/www/wisdomjobs.com/index.html. when the static page is stacked, the JS on that page will choose what to do given the url

Push State : You can in any case utilize spine steering to do your directing, yet don't utilize hashbangs. This will permit you to explore to URLs without really requiring a page invigorate.

Q2. What Is The Function Of Escape?
It gets the ongoing worth of a characteristic from the model yet returns the HTML-got away from adaptation of a model's property. It is useful in forestalling XSS assaults, assuming you are introducing information from the model into HTML.

Q3. What Are The Main Components Of Backbone.js ?
The fundamental part of Backbone.js are:

Model
View
Assortment
Switch
Occasion class object
Q4. Why You Have To Use Backbone ? Benefits?
By utilizing JavaScript with the negligible arrangement of information organizing ( models and assortments) and UI (sees and URLs) it empowers you to foster a web application
Spine is best valuable to foster MVC like web applications, single page web applications or complex JavaScript web applications in a coordinated and organized way without JavaScript code blending in with HTML
Offers key benefit restricting and custom occasions
Programming interface with lots of capacities
Strong occasion taking care of
Programming interface connetion over a RESTful JSON interface
Q5. How Might You Set Attributes Of A Model?
You can set ascribes of a model in two ways. Utilizing constructor boundary or .set().

See the underneath model:

var myObj = new MyClass({ attrib1: "Thomas", attrib2: 67});

//Or on the other hand we can set subsequently, these tasks are same
var myObj = new MyClass();
myObj.set({ attrib1: "Thomas", attrib2: 67});

Q6. What Is Model.attributes?
The traits property is the inner hash containing the model's state, generally a type of the JSON object addressing the model information on the server. It is in many cases a clear serialization of a line from the data set.

Q7. What Is View In Backbone.js?
Reflect what your applications' information models resemble.
Used to pay attention to occasions and respond likewise.
Q8. What Are The Tips/stunts/practice, With Respect To Model, You Follow?
The following are a few practices you ought to follow while working with Backbone models:

Get every one of the Current Attributes

obj.attributes gives an immediate reference to the characteristics and you ought to be cautious while playing with it. Best practice would propose that you use .set() to alter properties of a model to exploit spine audience members.

var individual = new Person({ name: "Thomas", age: 67});

var ascribes = person.toJSON();//{ name: "Thomas", age: 67}

/* This just returns a duplicate of the ongoing ascribes. */

var credits = person.attributes;

Approve Data Before You Set or Save It

Continuously carry out approve() strategy so Backbone approves the contribution prior to setting any property estimation. It guarantees that invalid information isn't put away on your server.

Individual = Backbone.Model.extend({
        // In the event that you return a string from the approve function,Backbone will toss a mistake
        approve: work( credits ){
            in the event that( attributes.age < 0 && attributes.name != "Dr Manhatten" ){
                return "You can't be negative years old";
            }
        },
        instate: function(){
            //Tie callback for mistake occasion
            this.bind("error", function(model, error){
                // We have gotten a mistake, log it, alert it or fail to remember it <img alt=":)" class="wp-smiley" src="http://synvistech.com/sites/wp-incorporates/pictures/smilies/basic smile.png" style="height: 1em; max-level: 1em;"/>
                alert( mistake );
            });
        }
    });

    var individual = new Person;
    person.set({ name: "Mary Poppins", age: - 1 });
    // Will set off an alarm yielding the mistake

    var individual = new Person;
    person.set({ name: "Dr Manhatten", age: - 1 });

Q9. How Might You Get The Attribute Value Of A Model?
You can get the worth of model characteristic by utilizing .get() strategy.

See the model underneath:

//Set credits
var obj = new MyClass({ attrib1: "Attribute1", attrib2: 50});

//Get credits
var attrib1 = obj.get("name");//"Attribute1"
var attrib2 = obj.get("age");//50

Q10. Make sense of What Is Modelbinder In Backbone.js ?
To make synchronization cycle of perspectives and models together, ModelBinder class is utilized.




CFG