Jun 02, 2021 Article blog
Previously, the w3cschool app developers on the headlines shared the "Tencent C-plus face", many programmers small partners want to ask if there is a front-end developer face and so on.
Well, today w3cschool here for the small partners to pick Tencent front-end first round interview two questions, and answer.
1, the characteristics of Angular:
#1 good application structure
Typically, we write JavaScript without a clear structure. W hile there is no problem writing small applications, this is clearly not suitable for large-scale applications. W ith AngularJS, you can organize the source code through MVC (Model - View - Controller) or MVVM (Model - View - View Model) mode. A ngularJS is an MVW framework where W stands for any project. You can organize your code modules, which can significantly improve the testability and maintainability of your application.
#2 two-way data binding
Data binding is certainly one of the best features of AngularJS. Y ou can declare a bound model to HTML elements. W hen the model changes, the view updates automatically and vice versa. This reduces a lot of traditional sample code and keeps models and views in sync.
#3 instructions
The AngularJS directive lets you quickly build applications using new HTML syntax. Y ou can create an API for reusable custom components and instructions. F or example, if you want to customize the date selector widget, you can create a component. I f you want a fancy file upload with a progress indicator you can continue to create a component. That's cool, isn't it?
#4 HTML template
AngularJS uses HTML templates, which makes things simple and allows designers and developers to work at the same time. Designers can create user interfaces in the usual way, and developers can easily work with data models of different UI components using declarative binding syntax.
#5 can be embedded, injected, and tested
The best thing about AngularJS is that it's a good team member. I t has never called for a full commitment. T he official AngularJS website says you can use AngularJS in your project as much or as little as you need. If you only need two-way data binding, you can introduce Angular and just use this feature.
AngularJS supports out-of-the-box dependency injection. I f you need something, you just call Angular to inject it. I t's as simple as that. This greatly improves testability because you can easily test the analog components.
AngularJS is always created with testability in mind. T hese modules and dependency injection systems make unit testing easier. I n addition, AngularJS provides a tool called a angler, which makes terminal-to-terminal testing easy. Therefore, the code you develop is always testable and maintainable.
That's not all! AngularJS also provides more useful features such as routing, filters, and animations.
2, the difference between slice, substr and substring
First, they both receive two parameters, slice and substring receive the start and end positions (excluding the end position), while substr receives the start position and the length of the string to be returned. Take a direct look at the following example:
1 var test = 'hello world';
2
3 alert(test.slice(4,7)); o w
4 alert(test.substring(4,7)); o w
5 alert(test.substr(4,7)); o world
Here's one thing to note: substring starts with the smaller of the two parameters and the larger parameter ends.
as:
alert(test.substring(7,4));
//o w
|
Then, when the received argument is negative, slice adds the length of its string to the corresponding negative number, and the result is an argument; S ubstr simply takes the result of adding the first argument to the length of the string as the first argument; S ubstring simply converts negative parameters directly to 0. The test code is as follows:
1 var test = 'hello world';
2
3 alert(test.slice(-3)); rld
4 alert(test.substring(-3)); hello world
5 alert(test.substr(-3)); rld
6 alert(test.slice(3,-4)); lo w
7 alert(test.substring(3,-4)); hel
8 alert(test.substr(3,-4)); Empty string
1 Note: IE mishandled substr to receive negative values, and it returns the original string.