Learn about math functions in javascript with examples, we have the largest and most updated math functions in javascript with examples information on alibabacloud.com
keyword, anonymous functions can effectively ensure that JavaScript is written on the page without polluting the global variables. This is very effective and graceful when adding JavaScript to a page that is not very familiar. In fact, Yui and its corresponding examples of the use of anonymous
The mention of closures always gives a very advanced feeling, and there are countless examples on the Internet. But I find that quite a few are not easy to understand. According to my observation, because these examples melted the concepts mentioned in the title, they tend to be more confused. So I want to piecemeal, and break it down into simple examples to expl
(yyyy) // sets the year
Settime () // set the time (date), millisecond value counted from January 1, January 1, 1970
Sethours (), setminutes (), setseconds () // set the hour, minute, and second
2.3 date reading Method
Getdate (mm, DD) // read a certain date of a month
Getmonth (MM) // read the month
Getfullyear (yyyy) // read year
Gettime () // read time (date), millisecond value counted from January 1, January 1, 1970
Gethours (), getminutes (), getseconds () // read hour/minute/second
2.4 Da
us with methods to expand and transform original objects. For example, we can add methods or attributes to known objects, including JavaScript core objects such as array, number, math, object, and Boolean, and custom classes.
For example:
Number. Prototype. tohexstring = function (){
Return this. tostring (16 );
};
VaR num = 10
Alert (Num. tohexstring ());
Output;
You can add a method for an object. In thi
The mention of closures always gives a very advanced feeling, and there are countless examples on the Internet. But I find that quite a few are not easy to understand. According to my observation, because these examples melted the concepts mentioned in the title, they tend to be more confused. So I want to piecemeal, and break it down into simple examples to expl
In this article, I will talk to you about functions and closures in JavaScript. If you need them, you can refer to the closure, next, let me take a look at the closure.
I. Description of closuresFor Functional Languages, functions can save internal data states. For a compiled imperative language like C #, because the code is always executed in the code segment a
JavaScript scope, context, definition and call of function objects, definition and call of anonymous functions, and closureThe introduction of closures always gives people a deep feeling that there are countless examples on the Internet. However, I found that a considerable amount of data is not easy to understand. According to my observations, these
Devil ". With the var keyword, the anonymous function can effectively ensure that Javascript is written on the page without causing global variable pollution. This is very effective and elegant when adding Javascript to a page that is not very familiar. In fact, YUI and its corresponding examples use a lot of anonymous funct
javascript| Functions | tutorials | strings
String functions that use JavaScript
String objects provide many methods, but few programmers make the most of them, which, for a programmer, cannot be said to be a flaw. Strings provide methods that can be used to manipulate characters, produce HTML tags, search strings, and
);}()
The three methods are equivalent. hedger Wang prefers 3rd for personal reasons, and I see 1st in actual applications.Iv. Application of anonymous Functions
The first sentence in Javascript's module mode is "global variables are the Devil ". With the VaR keyword, the anonymous function can effectively ensure that JavaScript is written on the page without causing global variable pollution. This is
is to use function statements to define a function, such as:
Copy Code code as follows:
Function abc () {
Code to process
}
Function ABC () {//code to process}
Of course, your function can also be with parameters, even with the return value.
View Plaincopy to Clipboardprint?
Function ABC (x,y) {
return x+y;
}
Function ABC (x,y) {return x+y;}
However, no matter how you define your function, the JS interpreter translates it into a function object. Fo
-used functions in JavaScript are described below. Although they are not very useful, at least they add some decoration to your code. These methods create HTML code from character objects to be displayed on a Web page.
Str.anchor ("Anchor1")
This is a string
Str.big ()
This is a string
Str.blink ()
This is a string
Str.bold ()
You can use the function to define the function in js. Call the function name directly. If there is a parameter, you can directly use the parameter, next I will introduce you to the definition and call examples of JavaScript Functions.
JavaScript function definition
The function definition uses the keyword function. Th
Arliang on the second floor !)Note:1. The type function of typeof a is in lowercase. Because Javascript is case sensitive, you must note that.2. huidiao (test) test does not need to write parentheses, because its parameter is just a variable. If it is written as (test (), the function will execute test (); this function, however, the Huidao function is not executed because test () does not return a value. The Huidiao parameter is actually undefined.O
functions in JavaScript are described below. Although they are not very useful, at least they add some decoration to your code. These methods create HTML code from character objects to be displayed on a Web page.
Str.anchor ("Anchor1")
This is a string
Str.big ()
This is a string
Str.blink ()
This is a string
Str.bold ()
This
The examples in this article describe the common API functions for JavaScript array objects. Share to everyone for your reference, specific as follows:
1. Concat ()
Connect two or more arrays and return the results
var a = [1,2,3];
var B = A.concat (6,7);
Console.log (a); [1,2,3]
Console.log (b);//[1,2,3,6,7]
2. Join (STR)
Separates all elements
The examples in this article describe JavaScript inheritance based on prototype chains and the use of call and apply functions. Share to everyone for your reference, specific as follows:
1. Inheritance is an important feature of object-oriented programming languages, such as Java, through the extend can achieve multiple inheritance, but in
], this is switched!})();}}Person. sayme ();
Case 3:Var Man = function (name, power ){This. name = name; // this is bound to the new object to be created.This. sex = 'man ';This. power = power;This. ability = function (){Document. write ('name: '+ this. Name + 'sex:' + this. Sex + 'power: '+ this. Power );If (this. power Document. write ('Oh, no, you power is little, you must strengthen it! ');}}}Var me = new Man ('shuqin', 60 );Me. ability ();
Case 4:Var generalsum = function (callback, args ){
called.SummarizeThe above explanation can be summarized as follows:
The declaration of a variable is advanced to the top of the scope, and the assignment remains in place
function declaration the entire "being ahead"
When a function is assigned to a variable as a value, only the variable is "advanced" and the function is not "advanced"
Feel more about yourself by practicing the above examples. Also, as a best practice: variable
Author: F. PermadiTranslator: Sheneyan (Zi Wu)English Original: INTRODUCTION to JavaScript functionsChinese translation (including examples): JavaScript functionsSub-note: a pretty good entry for function, personal feeling is quite classic.
Word Translation list:
Function: Functions (functional not translated)DECLARE
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.