Transferred from: http://www.cnblogs.com/yuanzm/p/3936376.html
1. Which of the following is the official Nodejs module?
A. Querystring B. Request C. Async D. Dns
I feel a bit of pain in this question, what is called the official module? In Nodejs, modules are generally divided into core modules, user-defined file modules. So I understand that the official module here is the core module, but even so, the problem is still more egg-ache, who remembers so much. But I found a more plausible explanation in StackOverflow: http://stackoverflow.com/questions/11364151/which-modules-does- Node-js-require-automatically. So I chose a D for this question.
2. Common git operations are
A. Add b.push c.mkdir d.fetch e.mv f.merge G.tag
For the keyword here "often", there is no obvious boundary, if you use more, it is called commonly used. The following non-stop analysis:
A:add: Adding the changes in the current working directory to the GIT index, and adding it to the GIT index will be credited to the version history, which is a step that needs to be done before committing.
B:push: Updates the local commit code to the remote repository, such as "Git Push origin", which updates the local code to the remote repository named Orgin.
C:mkdir: It should not be part of a common git operation.
D:fetch: Download the code from the server's warehouse. (Interacting with the server, downloading the latest code from the server)
E:MV: Renames a file, directory, or link.
F:merge: Merge the code downloaded from the server with the local code. or a branch merge.
G:tag: Create, List, delete, or validate a Label object (signed with GPG).
So the question should be: A B C E F G
3, the following statements are correct
The A.P element cannot contain the ancestor element of the div b.li element may be Li, but the parent element cannot be Li
The root node of the c.domtree is the offsetparent of elements within the BODY element d.body must exist
4, in the file/home/somebody/workspace/somemodule.js the first line refers to a module: Require (' othermodule '), ask required the order of the lookup module
A./home/somebody/workspace/mode_modules/othermodule/index.js
B./home/somebody/workspace/mode_modules/othermodule. Js
C.core MODULES named Othermodule
D./home/somebody/mode_modules/othermodule/index.js
First, Nodejs looks for modules in a way similar to JavaScript prototype chains or scope chains. According to the user's feedback, Bo Master consulted the "Nodejs" this book, book 18 pages mentioned:
(1): First, node in the current directory to find Package.json (COMMONJS Package Specification definition Package description file), through Json.parse () parse out the package description object, from which the main property specifies the file name to locate. If the file is missing an extension, it will go to the extension parsing step.
(2): If the main property has an incorrect filename, or if there is no Package.json file at all, node will use index as the default file name, then look for Index.js, Index.node, Index.json.
(3): If no files are successfully located during directory analysis, the custom module goes to the next module path to find it. If the module path array is traversed and the target file is still not found, a lookup failure exception is thrown.
According to the above idea, first should look for Package.json file, see if there is no core module, should be c first, Othermodule is not the core module, then should go into the extension analysis step, should be to find othermodule. JS, corresponding to B, followed by the index as the default file name, that is, a, and then the previous file directory D, so the blogger gives the answer is: C B A D
5. Fill in the code so that Mysort () can make the incoming parameters appear in order from small to large.
function Mysort () { var tags = new array ();//Use an array as a parameter to store the container please add your code return tags;//return the sorted array}var result = Mysort (50,11,16,32,24,99,57,100);/number of incoming arguments indeterminate console.info (result);//Display result
This problem is relatively simple, is a water problem, directly on the code:
function Mysort () { var tags = new Array (); for (var i = 0;i < arguments.length;i++) { tags.push (arguments[i]); } Tags.sort (function (compare1,compare2) { return compare1-compare2; }); return tags;} var result = Mysort (50,11,16,32,24,99,57,100); Console.info (result);
8. Please write a personal github address
Https://github.com/yuanzm
9, please use native JS to implement a div can be dragged, need to consider browser compatibility.
As shown in the code:
#drag1 {width:50px; height:50px; Background-color: #404040; Cursor:pointer;}</style><body> <div id = "DRAG1" ></div></body><script type= "Text/javascript" >window.onload=function() { functionDrag (obj) { This. obj =obj; } Drag.prototype={constructor:drag, getinitposition:function(e) {e= e | |window.event; varEx,ey; if(E.pagex | |e.pagey) {EX=E.pagex; EY=E.pagey; } EX=E.clientx; EY=E.clienty; varPositionx = ex- This. Obj.offsetleft; varPositiony = EY- This. Obj.offsettop; return{X:positionx, Y:positiony}}, Getmousecoordinate:function(e) {e= e | |window.event; if(E.pagex | |e.pagey) { return{x:e.pagex, y:e.pagey}; } return{X:e.clientx+ Document.body.scrollLeft-Document.body.clientLeft, Y:e.clienty+ Document.body.scrollTop-Document.body.clientTop}; }, Initdrag:function() { varTempthis = This; This. Obj.onmousedown =function(e) {varINITP =tempthis.getinitposition (); Document.onmousemove=function(e) {varMOVEP =tempthis.getmousecoordinate (); TempThis.obj.style.marginTop= movep.y-initp.y + "px"; TempThis.obj.style.marginLeft= movep.x-initp.x + "px"; } document.onmouseup=function() {Document.onmousemove=NULL; Document.onmouseup=NULL; } } } } vardrag = document.getElementById ("Drag1"); varDragelement =NewDrag (Drag); Dragelement.initdrag ();}</script>10. How to tell if the browser is IE or Firefox, with Ajax implementation.
If you want to use Ajax to determine whether it is IE browser or Firefox browser, you should pass the XMLHttpRequest object.
Let's start with a brief introduction to this object:
(1) All modern browsers support XMLHttpRequest objects (IE5 and IE6 use ActiveXObject).
(2) All modern browsers (ie7+, Firefox, Chrome, Safari, and Opera) have built-in XMLHttpRequest objects.
Therefore, the author's understanding of the problem is to write a XMLHttpRequest-based JS script, under IE or Firefox browser to determine exactly what kind of browser environment, the code is as follows:
var xmlhttp;if (window. XMLHttpRequest) { //code for ie7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest (); Alert ("Your brower is not IE");} else { //code for IE6, IE5 xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP"); Alert ("Your brower is IE")}
2015 Ali School recruit front-end pen questions