Discover for loop syntax javascript, include the articles, news, trends, analysis and practical advice about for loop syntax javascript on alibabacloud.com
, if you do not understand it, use TypeOf to print the data type as much as possible. In the development phase try not to understand the multi-debug and alertOften in the process of debugging we, we write a lot of logic when we can use the Return key organization code to execute down until the debug succeeds in the return to clear out.Logical judgment: or (| |) and () non (!)Non, True and False, False also true for example:!false = TRUE//!true= false;Or: One is good (true), all are good, return
;BreakDefaultcode block;}var i= "1";while (condition) {Declaration conditions;i++;}do {Execute the statement;}while (conditions);for (Var i=0;iDeclaration conditions;}"Some exercises"1. Bubble sort: three timesvar arr=[12,11,5,7,9,23];for (Var i=0;ifor (Var j=0;jif (Arr[j]>arr[j+1]) {var temp=arr[j];ARR[J]=ARR[J+1];Arr[j+1]=temp;}}}Console.log (arr);2. Determine if a number is prime (prime)for (Var i=2;ifor (Var j=2;jif (i==j) {Console.log (i);}if (i%j==0) {Break}}}3. Prompt the user to enter th
://www.baidu.com", "_blank", "width=500, height=500");Note: to remove the browser blocking Feature.(5). TimerA, Window.setinterval (); Setting the loop TimerThe SetInterval () method invokes a function or evaluates an expression according to the specified period (in milliseconds).SetInterval (code,millisec,lang)
Parameters
Describe
Code
Necessary. The function to invoke or the code string to Execute.
Basic JavaScript syntax
This article mainly introduces the basic syntax of JavaScript, including the basic knowledge of comments and writing formats. For more information, see
JavaScript consists of the HTML tag of the JavaScript
objects.This example creates an object named "Person" and adds four properties to it:InstancePerson=new Object ();Person.firstname= "Bill";Person.lastname= "Gates";person.age=56;Person.eyecolor= "Blue";There are many different ways to create new JavaScript objects, and you can also add properties and methods to existing objects.You will learn more about this in the chapters later in this tutorial.Accessing the properties of an objectThe
This article introduces the basic (commonly used) grammar of JavaScript for your reference.
Overview
Let's talk about how JavaScript should be written. Two forms, one is to write JavaScript directly in the HTML page, the other is to exist in the *.js file and then referenced in the page.
Write directly, that is, can be placed in
Reference mode
number?var a = IsNaN (b); IsNaN--->is not a numberA is true is not a numberA is false is a number(4), operatorMath operators: +,-*,/,%, + + 、--(7)Relational operators:>, Logical operators: | |, ,!Other operators: + =,-=, *=,/=,%=,?:(5), statementOrder, branching, looping.1. Branch: If.....else2. Loop: For(6), array1. Definition:var a=new Array (); Its length is dynamically variable and can be placed in any type of element.2. Method:A.sort (); sort an
into automatic conversion and casting, the general use of casting.other types are converted to integers: parseint ();Other types converted to decimals: parsefloat ();In addition to determine whether it is a valid number type: IsNaN ();is a number then returns false, not a number if it returns True, as follows:var a=prompt ("Please enter a number")if (a!=null)var B=isnan (a)if (b==flase)Then the input of a is a number, continue to go down, if not the number is prompted to enter the error!4: ope
JSHint-Use of javascript syntax checking standard tools and integration with Sublime
1. Install jshint of nodejs
Install the Node. js Environment
Install nodejs jshint [4] csshint
Ii. install and configure jshint in sublime
Method 1: Use Sublimelinter to support css and other language Verification
Method 2: Use Sublime JSHint Gutter and only support js Verification
Iii. Three con
This article mainly introduces the JSX grammar learning tutorials in the React framework of JavaScript. React is a highly popular js framework developed and open-source by Facebook. For more information, see
What is JSX?
When using React to write components, JSX syntax is usually used. It looks like the XML tag is directly written in Javascript code. In fact, th
;Math.ceil () upward rounding;Math.floor () downward rounding;Math.Abs (): Take absolute value;Math.max (x, y): Maximum number;Math.min (x, y), minimum number;Math.pow (x, y): several times;MATH.SQRT (): Open square;Array: Store multiple things;JSON: Save multiple things;JSON = {Key-value pairsname1[keys, key]:value1[values, value],name2[keys, key]:value2[values, value],}The difference between JSON and arr:1:lengthundefinedarr.length;2: The way of subscript attribute arr[0];3: The order has no o
This article starts with the blog Park and continues to update the front-end series on GitHub. Follow me on GitHub, get started and go to the advanced front.
The following is the text.
If statement of the most basic if statementStructure of the IF statement: (format) if{ // 条件为真时,做的事情 }else{ // 条件为假时,做的事情 }If statements also become "SELECT statement", "conditional judgment statement", we use the following image to explain.Multi-Branch If statementFormat
This article begins with the introduction of javascript, this section describes the javascript syntax and precautions, Dynamic Language, reference of external JS files, variable naming rules, and determination of whether block-level scopes are declared or not, this is an introduction to quite good basic syntax and is r
Use of Regular Expressions in Javascript and basic syntax,
Previous
Regular expressions may be a bunch of incomprehensible characters in people's minds, but these symbols implement efficient string operations. Generally, the problem is not complicated, but it becomes a big problem without a regular expression. Regular Expressions in javascript are very important
head or body tag(2) external reference Third, the output of JS(1) Manipulating HTML elementsUse the document.getElementById (ID) method and use innerHTML to get the content of the inserted element document.getElementById ("demo") is a JavaScript that uses the id attribute to find HTML elements Code.InnerHTML = "Paragraph changed." Is the JavaScript code used to modify the HTML content (InnerHTML) of an ele
"; // Output paragraph: document.getElementById ("MyP"). Innerhtml= "This is my first paragraph.";JavaScript Multi-line commentsMultiline comments start with/* and end with */.The following example uses a multiline comment to interpret the code:Example/* The following code will output a title and a paragraph and will represent the beginning of the home page */ document.getElementById ("myH1"). Innerhtml= "Welcome to my homepage";d Ocument.getelementby
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.