JavaScript
JavaScript
exists all the time. Es6 inherits
document.createElement
js is based on prototype inheritance, and there are no good keywords to implement interface and inheritance, so it needs to be simulated. You can find information about js design patterns to get the simulation.
es6 introduces classes and inheritance, but it is not perfect compared to traditional object-oriented languages. If you must use complete mechanisms such as inheritance and interfaces, you can choose to use typescript.
Yes, both es6 and typescript are implemented. It's not realistic to implement it by yourself. Take a look at es6's
es6's class inheritance
all the time. Encapsulate inheritance and polymorphism.
conceptually, there is no interface in syntax. Although there are a lot of inheritance in es5, except for prototype chain inheritance, everything else is copied. Es6 has an extends, equivalent to inheritance in java. For oo, let's use ts. Es6 is not enough.
you can use a factory function to reflect the form of the interface
var instance = function(){
var var0 = 0;
var interface = {
var1 : var0
};
return interface;
}
inheritance is also called replication, reuse code
var father = {
firstName: 'liu',
lastName: 'oneDog',
age: 20
};
var son = {
lastName:'twoDog',
age: 2
};
/**
*
*/
Object.assgin(son,father);
/**
*
* prototype
*
*/
There is an input input box in the page. If the other party enters < H2 > Hello < H2 > , it will be automatically converted to large bold text. how to output strings directly from p.content without parsing H2 tags into large bold? ${value} `; th...
the requirement is: ajax I can t write well no matter how I write it. Look at the Internet, most of them add an id, to the form tag and then new FormData ($( - sharpid ) [0]), and then submit it at once, so my three fields are useless, aren t...
first of all, the source code is like this input(v-model="num" @keyup="search") -sharp .prompt(v-show="lists!=0") -sharp .list(v-for="(i,n) in lists" :key="n") {{i.name}} how vue listens to let the...
console.time () and console.timeEnd () can print the execution time of the program. (function(){ console.time( index ); var div = document.getElementById( div ); div.onclick = function(){ alert( 123 ); }; console.timeE...
Code: ready.touch = function (elem, fn) { elem.addEventListener( click , function (e) { fn.call(this, e); }, false); }; question: what is the purpose of this here? Who does it point to when the click event is ...
requirements: the page has a large image as the background, which requires that no matter how the browser size changes, the background image will always be in the same proportion (will not be deformed), and will always be covered with the entire browser...
currently encapsulated table plug-ins are as follows: (function ($) { function Table() { this.config = { } }; Table.prototype = { table rend: function (config) { return this; ...
The scene appears in a rich text editor. I want to select a piece of text, and then a tooltips appears above the selected text . it is not clear which method should be used to get the start and end points of a selection (selection) relative to the offs...
center[0].onmousedown = function () { docMove(); document.onmouseup = function () { document.onmousemove = null; document.onmouseup = null; }; }; function docMove() { ...
wrote a custom video playback control that you want to call out on the mobile by clicking on the video. But the video tag does not respond to this click event. how do ordinary video players call out playback controls? ...
For the webpack+vue project, I want to use the "runtime version " of vue, but I also want to use the template feature. The official website says that using vue-loader is fine. Webpack I configured vue-loader, to use the "runtime " version, which will ...
question: how can other event listeners or functions get this Dom state after an event listener method changes the Dom state (such as hiding)? usage scenarios: jquery, vue ...
Please see the preview . When you scroll to the upper boundary of the page to cover the half of the barrage, you will see that the barrage slowly squeezes the screen down again, and in the process, the page keeps bouncing. For demo, please see here ...
css2.2 document stipulates: for elements whose position is static or relative , containing block is content box of the most recent ancestor element block container box (except margin , border , padding ); can be obtained: the contain...
the elements of the embed tag selected on the page are copied and cannot be pasted. Does anyone know why http: iwebad.com video 3440. is that the flash of this page cannot be copied ...
the elements of the embed tag selected on the page are copied and cannot be pasted. Does anyone know why http: iwebad.com video 3440. is that the flash of this page cannot be copied ...
document.getElementsByClassName("current")[0].onclick = function () { 1 alert("abv"); for(var i = 0; i< listShow; iPP ) { document.getElementsByClassName("sojob-item-ma...