JavaScript parentheses have five kinds of semantics
Semantic 1, Function declaration time parameter table
Copy Code code as follows:
function func (ARG1,ARG2) {
// ...
}
Semantic 2, used in conjunction with some
1, traversing all the controls in the facefunction Findcontrolall (){var inputs=document.getelementsbytagname ("input");for (j=0;jif (inputs[j].type== "text")//here, find all controls with text of the page, or you can set the type of control you
08 A company JS interview question, the position is JavaScript engineer (go to Google)
The interviewer asked me how to clone an array, when I thought of the next JS object without the Clone method, Java object has.
So how do we get a new array?
I
The principle is to loop through the controls on the Web page, and then set the Disabled property to true.
The code is as follows:
Copy Code code as follows:
The following are the types of these controls:
can be obtained by
window.open () Support environment: javascript1.0+/jscript1.0+/nav2+/ie3+/opera3+
window.open (Pageurl,name,parameters)
Pageurl as a child window path
Name pop-up window
Parameters for window parameters (comma-separated arguments)
alwayslowered |
First, local variables are declared after use and do not affect external variables with the same name
Copy Code code as follows:
var x = 1; --> external variable X
function fn () {
alert (x); --> undefined local variable x first
In a recent project, you will not be able to debug JavaScript code when submitting to a child page, sometimes this problem, we can not normal in the browser, see our child page JavaScript code, so can only use the original alert or Console.log (),
Each function has a prototype attribute, called a prototype. Each object also has a prototype, which can be accessed through __proto__ in the Firefox/safari/chrome/opera, and no related interfaces are provided in IE6/7/8.
Copy Code code as
Today encountered a need to use JavaScript to replace some of the parameters in the URL of the requirements, remember that not long ago from the internet to find a parseurl function, just can use this implementation, code collation as follows:
Previously in Yuber GitHub issues saw the use of JS detection of CPU usage, feel very good.
In particular, the implementation of a bit, plus a histogram of the function can be intuitive to see the situation of CPU utilization.
See the effect:
Before we begin our formal presentation, we'd like to look at the JavaScript promise:
Copy Code code as follows:
var p = new Promise (function (resolve, reject) {
Resolve ("Hello World");
});
P.then (function (str) {
alert
The match function in JavaScript uses a regular expression to find the string and returns the result of the lookup as an array, which is useful in practical development, using the following methods:Stringobj.match (RGEXP)Where stringobj is a
Saying today is just a cursory glance at the source of proxy switchysharp, it has harvested a lot of things, including this article to introduce the reading and saving files.Because Google does not yet provide the ability to sync plug-in data,
Copy Code code as follows:
/**
* Returns a random lowercase letter
*/
function Getlowercharacter () {
Return Getcharacter ("lower");;
}
/**
* Returns a random capital letter
*/
function Getuppercharacter () {
Return Getcharacter
JavaScript gets CSS property value method: getComputedStyle and Currentstyle1. For the inline CSS style of the element (hello), you can directly use Element.style.color to get the value of the CSS property directly;2. However, external-defined CSS
Sometimes you need to get the size of the picture, which needs to be done after the picture is loaded. There are three ways to achieve it, as described below.
First, the Load event
Copy Code code as follows:
img-load
From Mozilla Aurora 11, Firefox has implemented some new features, one of which is the basic implementation of the battery state interface. This simple interface can provide you with information about the current battery charge, whether it is
1. Convert numbers to Strings
A. To convert a number to a string, simply add an empty string to it:
Copy Code code as follows:
var n = 100;
var n_as_string = n + "";
B. To make the number more explicitly converted to a
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service