/Typing command CTRL + C terminate the program, we change the JS file output content into Chinese characters (such as: Hello), and run JS file again, you will see Chinese contentThree. AnalysisWe need to build an HTTP server (such as PHP Apache and. NET IIS, etc.) to display content on the page, which is browser access.Nodejs only needs to introduce the HTTP module (and of course there are other kinds of of
closures in loopsTake a look at the following example:This function returns an array of functions. On the surface, it seems that each function will print its own index value. But actually each function prints 10. Because each function refers to the same variable i. When the Foo () function returns, the value of I becomes 10, so each function executes with a result of 10.By creating another anonymous function, you can make the behavior of the closure conform to expectations.Performance issuesAft
NPM: Nodejs Package Manager
Express: Server-side more popular MVC framework, processing service requests, routing forwarding, logical processing
Mongoose: MongoDB wrapper for easier database use
http://Socket.io to implement a service-side and client socket communications solution
backbone: Client MVC framework, writing client applications (watercress says)
coffeescript: Improving the readability and robustness of JavaScript
Zombie: Browser subset, writing HTML parser, light Ja
1. Since multiline strings are more \n cumbersome to write, the newest ES6 standard adds a multi-line string representation, using ' ... '`这是一个多行字符串`;2.字符串常见的操作如下:// 13要获取字符串某个指定位置的字符,使用类似Array的下标操作,索引号从0开始:s[12]; // ‘!‘s[13]; // undefined 超出范围的索引不会报错,但一律返回undefined3. It is important to note that the string is immutable, and there is no error if you assign a value to an index of the string, but it does not have any effect:var s = ‘Test‘;s[0] = ‘X‘;alert(s); // s仍然为‘Test‘4.JavaScript provides som
How to get elements in JSTo get an element by an ID name:document.getElementById (' ID of element ')Events: Mouse events, keyboard events, system events, form events, custom events ....OnClick//Click eventsonmouseover//mouse move inonmouseout//Mouse awayONMOUSEDWN//Press to show something laterOnMouseUp///mouse raised an eventOnMouseMove//Stroke eventsHow to add an event:element. onmouseoverFunction: Can be understood as-command, do somethingFunction name () {//Definitely not active!Document get
the ES6 arrow function. Without a break statement, if you want to terminate prematurely, you must put the foreach () method in a try block and throw an exception.②map ()Passes each element of the called array to the specified function and returns an array that contains the return value of the function.Arr6_5_2 = [2, 4, 33, 111, 99, 66]; var arr6_5_3 = Arr6_5_2.map (function (x) {return 2*x}); Each value in the array is Console.log (Arr6_5_3); =>[4, 8, 66, 222, 198, 132]③filter ()Returns a sub
Use of regular expressions in JS
function Myvalid () {
var errormsg = "";
var res = true;
Get the value you want to validate.
var receivename = $ ("#receiveName"). Val ();//Name
var receivemobile = $ ("#tMobile"). Val ()/mobile number
var Validcode = $ ( "#validCode"). Val ()//Verification code
var regname =/^[\u4e00-\u9fa5]{2,4}$/;//authentication name
var regmobile =/^1[3|4|5|7|8][0-9]\ d{8}$/;//Verification Mobile phone
v
A view of the ASP's JavaScript program, convenient for everyone to learn ASP program (JS)
http://aspage.yeah.net/------------------------
--------------------from "rainbow drizzle"--------------------------------------------------
Program Author: Rainbow Rain chy.126.com
var autotop=new Array ()
Autotop[1]= ""
Autotop[2]= ""
Autotop[3]= ""
Autotop[4]= ""
Autotop[5]= ""
var autoend=new Array ()
Autoend[1]=
); Xhr.send (str); }node. JS:varHTTP = require (' http ');varQueryString = Require (' querystring '));varurl = require (' URL '));varUtil = require (' util ')); Http.createserver (function(req, res) {//Staging request body Information varBODY = ""; //Request LinkConsole.log (Req.url); //whenever the request body data is received, it is added to the postReq.on (' Data ',function(chunk) {body+ = chunk;//be sure to use + = if body=chunk, because the request favicon.ico,body will be equal to {
() {}, the interface is prepared for the correct behavior to be available earlier.Use $ (document). Ready () {} is generally superior to the trial onload event handler, but it must be clear that attributes such as the height and width of the image are not necessarily valid at this time because the supporting files may not be home-finished.The onload event is usually written in the following form:function MyFunction () {//your code};window.onload = MyFunction;Or:Window.onload = function () {//yo
1: read a book to understand the concept!The purpose of this book is to have a basic understanding of js!This time should not be too long. Check the progress, days to a week!2: when surfing the Internet, pull the source code based on different page effects!Take notes! Build your own results! Common online knowledge must be the most important thing for JavaScript!3: when reading the source code, you should combine the books with Baidu to
other major banks.DD> DL> DL> DT>aOnClick= "Show (4)"href= "javascript:void (0)">Q: What is the payment method of insurance indemnity, surrender guarantee and insurance money?a>DT> DDID= "Deal4"style= "Display:none">A: Bank Transfer payment, you only need to provide a bank account at the time of application, you can easily collect insurance premiums, eliminate the risk of cash transactions. The banks that we can transfer paymen
keyword, so it is an anonymous function. function expressions, like other expressions, must be assigned before they are used.The form of the (1) function declaration is known as the function statement. A statement cannot begin with a function expression because the official syntax assumes that the statement that begins with the word function is a function statement. The workaround is to enclose the function call in parentheses.1 (function () {2 var hidden_variable; 3 /
the beginning of the design, in order to facilitate learning for beginners, does not require the use of VAR declaration variables. This design error has serious consequences: If a variable is used without a var declaration, the variable is automatically declared as a global variable:i = 10; // i现在是全局变量In different JavaScript files on the same page, if you do not have var to declare it, the variables i will be used, causing i the variables to interact with each other, resulting in hard-to-debug
page.You can use jquery to perform the first load$ (' a[data-toggle= ' tab "]). On (' Shown.bs.tab ', function (e) { e.target//This parameter enables you to get the tab information for activation E.relatedtarget The information of the tab before activating})[JavaScript]View Plaincopy
Fade in effectFor each.tab-paneAdd to.fadeLets you have a fade-in effect on a tab. The content area corresponding to the first tab must also be added.inCauses the initial content to have a fade-i
1.push () and Unshift () returns the new array length after executing the methodWhen the pop () and Shift () methods are executed, the removed items are returned;Shift () Gets the first pop () to get the last itemPush () adds item unshift () from the previous Add itemMemorizing method: The letter is short is to take an item, the letter is long is added, pop () is shorter than push (), so is to take, learn from each other;Push () is added from the fron
participates in the argument:When a function is called, a copy of the function's arguments is copied to the formal parameter, and the number of the function's shape participation arguments can be different.var i= 0;function Getsum (a,b,c) {///in the definition of functions, the parameter used is called the formal parameter, the role of the position to occupyArgumentsA = a | | 0;b = B | | 0;c = C | | 0;console. log (A+b+c);}Getsum (10,20);//When the function is actually called, the incoming data
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.